Hello guys,
I'm would like to reset my timer when analog input is incoming and only keep run my timer when no input is incoming anymore to run sleep function, for example.
here is my timer:
unsigned long timer = 0;
unsigned long countdownTimer = 20000;
void loop () {
if (millis() > timer + countdownTimer) {
Serial.println("Timer is ready");
timer = millis();
ESP.deepSleep(0);
}
}
this is how it looks right now. Timer just starts when esp is on and keep running 20 sec.
But I need to set up timer = millis();
when analogRead(A0)
input is incoming.
Can someone help me with the function pls?