adding low temp alert to arduino code dht22

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?
  }

notsolowki:
..but Serial.println(h1); runs regardless? can someone please help? thanks

Hi

Learn basics about using if()-function. There you'll find a difference between:

if (someVariable > 50)
{
    // do something here
    // do something else here
}

..and:

if (someVariable > 50)
    // do something here
    // do something else here

Hint: Something to do with the brackets :slight_smile:

Tommi

//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?
}

thankyou this link ' https://www.arduino.cc/en/Reference/If 'was just what i needed