Hi,
i am looking for a way to create a 60 sec. timer that starts over counting immediately when triggered when a value becomes true. My brain is a little stuck here. IT's probaly that simple that I am overthinking it. Sorry, forgot ESP32 and Arduino IDE.
Say
var = 0
Code for 60 seconds Timer function
Code that checks every 0.5 sec for change in var in the 60 seconds
Anywhere in those 60 seconds var can become +1
If that happens write down the elapsed time
Timer starts over
If timer reaches 60 and var is false
//Not important for this example
Timer resets and starts over
Any ideas?
Drop that partially implementation, what do you really want to do?
You can use millis() for all the timing.
I want to monitor a pulse within a 60 seconds timeframe.
When a pulse comes in within the 60 sec. timer interval
restart timer immediately
When no pulse is received print within the 60 sec. timer interval
print timeout
restart
Use state change detection (see examples) to detect the pulse. millis() can be used for timing.
In pseudo code it will look a bit like:
if(pulseDetected){
pulseMillis = millis();
}
//separate check
if(!timeOut && (millis() - pulseMillis >= TimeOutTime)){
timeOut = true;
Serial.println(F("timeout"));
}
Where you reset the time out is up to you.