i seem to be having another problem, i commented next to the line of code im having an issue with. if 'h1' is greater than 90.00 Serial.println(h1) keeps running. Serial.println("Warning Humidity Low"); only runs when it is suppose to but Serial.println(h1); runs regardless? can someone please help? thanks
alertcurrent = millis();
if (alertcurrent - alertprevious >= alertperiod) {
alertprevious = alertcurrent;
if ( f1 < 76.00 )
Serial.println("Warning Tempature Low");
if ( f1 > 88.00 )
Serial.println("Warning Tempature High");
if ( h1 < 90.00 )
Serial.println("Warning Humidity Low"); // anything below this line runs constantly ??
Serial.println(h1); //Why does it keep printing this even if h1 is greater than 90.00?
}
//Why does it keep printing this even if h1 is greater than 90.00?
Because it is not conditional on the test.
If you always use { and } to enclose code blocks, even if they are only 1 line, then you will make life easier for yourself
if ( h1 < 90.00 )
{
Serial.println("Warning Humidity Low"); // anything below this line runs constantly ??
Serial.println(h1); //Why does it keep printing this even if h1 is greater than 90.00?
}