Ok i have float1 being bottom float and float2 being a fail safe switch. the delay is to prevent clicking so the water level goes little above bottom switch which works. But i cant seem to get the 2nd timer (ontime2) working for when the my supply is empty (when pump runs longer than timer and float1 doesnt trip) maybe theres simpler loop just has me stumped. thanks
void topoff2()
{
if (digitalRead(float1) == HIGH && digitalRead(float2) == LOW && toptoolong == FALSE){
digitalWrite(Relay_4, RELAY_ON);
onTime = millis();
onTime2 = onTime;
}
if((onTime > 0 && millis() - onTime > 30000) || digitalRead(float2) == HIGH ){ // runs 30sec after float rises
digitalWrite(Relay_4, RELAY_OFF);
onTime = 0;
}
if (digitalRead(float1) == HIGH && (onTime2 > 0 && millis() - onTime2 > 40000)){ // if running longer than 40s topoff empty.
digitalWrite(Relay_4, RELAY_OFF);
toptoolong = TRUE;
}
if (digitalRead(float1) == LOW && digitalRead(float2) == LOW){ //resets too long timer id float goes back up.
toptoolong = FALSE;
onTime2=0;
}
}