@ato_arduino I can't test this from under the umbrella, but this is what might work. It is @gcjr's Flush timer machine, conditioned upon the ATOsolenoid:
// start or continue hourly 20 second flushing
if (digitalRead(ATOsolenoid) == HIGH) {
switch (state) {
case Idle:
if (msec - msec0 >= MsecIdle) {
msec0 = msec;
state = Flush;
digitalWrite(FlushSolenoid, HIGH); //Switch Solenoid ON
}
break;
case Flush:
if (msec - msec0 >= MsecFlush ) {
msec0 = msec;
state = Idle;
digitalWrite(FlushSolenoid, LOW); //Switch Solenoid OFF
}
break;
}
}
else { // ATOsolenoid is LOW here, amIRight?
// kill the flush and reset waiting for ATOsolenoid pin to go HIGH again
state = Idle;
digitalWrite(FlushSolenoid, LOW); //Switch Solenoid OFF
}
BTW I've been noticing these lines of code:
digitalRead(lowEye);
digitalRead(highEye);
digitalRead(ATOsolenoid);
Totally correct code that does… nothing. They read a pin, and then fail to do anything with the value that got read. It may well be the compiler just tosses them overboard.
HTH
OK, I can already see that the "kill and reset" logic may be flawed, I'll see if anyone has fixed it before I get to the lab.
a7