This is the part of the code with the error:
int value = analogRead(LM351);
float Temperature = value * 500.0 / 1023.0;
lcd.setCursor(6,0);
lcd.print(Temperature);
lcd.setCursor(11,1);
int value1 = analogRead(LM352);
float Humidity = value1 * 500.0 / 1023.0;
lcd.setCursor(10,1);
lcd.print(Humidity);
if (Temperature > 24){
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("");
}
else {
digitalWrite(motor, LOW);
digitalWrite(LedRed, LOW);
digitalWrite(LedGreen, HIGH);
lcd.print("");
}
if (Humidity > 10){
digitalWrite(motor, HIGH);
lcd.print("");
}
else {
digitalWrite(motor, LOW);
lcd.print("");
}
delay(1000);
}
By right, the motor should spin if the temperature is more than 24 or humidity is more than 10. But when I ran this code, the motor only spun if the humidity was more than 10. But when humidity was less than 10 and temperature was more than 24, motor did not spin.
The reason for this is as I am checking one variable after the other, is there a way in which I can check each variable independentaly from the other?