I want to start the my relays in off state ,Thats why i set all out puts to HIGH.And i also set exhaust pin to LOW when temperature starts rising above 30,Then only the counting to start.
if (exhaustState == LOW) {
if ((roomtemp >= 30) && (digitalRead(coolerpin) == HIGH )) {
digitalWrite(exhaustpin, LOW ); // if temperature increses above 30 the exhaust starts to work
startingCount = millis();
}
}
if (digitalRead(exhaustpin) == LOW) {
exhaustState = HIGH ;
if ((millis() - startingCount) >= 600000) {
digitalWrite(coolerpin, LOW );
digitalWrite(exhaustpin, HIGH ); // after the starting of exhaust fan it wait for 10 minutes ,then it turn
// on the cooler and turns off the exhaust fan
}
}