Arduino UNO -temp./humid. program code modification

Thread Starter

neo1111

Joined Jan 11, 2014
28
Hy there.
Let me explain what i intend to do: using 2 pins , if the temperature is over 40 degrees then set digitalpin3(LOW) --> 0V.(is an example)
If humidity is over 95 % , then set digitalpin3(low).
But, if the temperature is over 40 , only one pin is LOW(OV) , the other one is (HIGH) amd the other way for exceeding 95% for humidity .
At first the pins must be on HIGH.(both) initially .
I have the program but my modifications havent led me anywhere.
I want to modify this program because it is tested and works just fine .
Any ideas?Thx!
Code:
Code:
#include "DHT.h"                       
#define DHTPIN 9                        
#define DHTTYPE DHT22                    
DHT dht22(DHTPIN, DHTTYPE);              
#include "Wire.h"                         
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27,16,2);          
void setup()
{
  Serial.begin(9600);                     
  Serial.println("DHT22 serial");
dht22.begin();                            
lcd.init();                                                                    
lcd.backlight();                          
lcd.print("  OK ");
lcd.setCursor (0, 1);
lcd.print(F("Reading data"));
    delay(5550);

}

void loop()
{
  lcd.setCursor(0,0);
  float t = dht22.readTemperature() ;      
  float h = dht22.readHumidity() ;         
  Serial.print("Temperature is: ");       
  Serial.print(t);                      
  Serial.print(" C\t");                   
  Serial.print("Humidity is: ");          
  Serial.print(h);                      
  Serial.print(" %");                   
lcd.setCursor(0, 0);                     
lcd.print("Temp.  : ");                   
lcd.setCursor(9, 0);                    
lcd.print(t);                         
lcd.setCursor(15, 0);               
lcd.print("C");                       
lcd.setCursor(0, 1);                     
lcd.print("Umidit.:       ");                  
lcd.setCursor(9, 1);                    
lcd.print(h);                            
lcd.setCursor(15, 1);                   
lcd.print("%");                          
}
 

shteii01

Joined Feb 19, 2010
4,644
digitalpin3==digitalpin3

You said you are using 2 pins. Then you say you are using one pin, digitalpin3. Make up your mind.
 

Thread Starter

neo1111

Joined Jan 11, 2014
28
digitalpin3==digitalpin3

You said you are using 2 pins. Then you say you are using one pin, digitalpin3. Make up your mind.
I gave an axample: of course i'm supposed to use 2 digitalpins (digitalpin3 &digitalpin4).3-for temp/ and 4-humidity
 

Thread Starter

neo1111

Joined Jan 11, 2014
28
digitalpin3==digitalpin3

You said you are using 2 pins. Then you say you are using one pin, digitalpin3. Make up your mind.
This condition is ok?
Code:
if (isnan(t) > 40) {
  digitalWrite(2,LOW);}
  else {
    digitalWrite(2,HIGH);
  }

if (isnan(h) > 90) {
digitalWrite(3,LOW);}
   else {
     digitalWrite(3,HIGH);
   }}
I must have "0" logic on pin 2 when the temperature is over 40 and also "0" on pin3 when the humidity is over 90% ; else , they must be "1".
I need " 0" because when i give 0V to a different pin - it will turn on a 7 digit segment .
 
Top