Seems you don’t need to check timings, right? If you see a High then you know you are in mode 1
Do you want to know only at the start of the code? You could use an active wait or pulseIn() in the setup
If you need to monitor this all the time then either check during the loop (assuming it does not take more than 64ms) or attach an interrupt pin to the signal and trigger upon a low to high transition
Using some sort of time reference? I'd start out like this..
#include <timeObj.h>
timeObj timeout(3000); // Timer set to 3 seconds. Maybe set for smidge longer?
bool active; // Our state variable. Saves if things are active or non active.
void setup() {
active = false; // Npt seen a pulse so we'll say, non active. (false)
}
// Is this pulse high or low?
bool readState() {
bool highLow;
//fill this part in..
// Is CURRENT input state high (true)? or low (false)?
return highLow;
}
void loop(void) {
if (readState()) { // If the pulse is high..
active = true; // Then it must be active.
timeout.start(); // And we'll restart the timeout timer.
}
if (timeout.ding()) { // If we've seen only a low pulse for 3000 or so ms..
active = false; // Then we are no longer active.
}
if (active) { // If, (after doing the checks) the state is active..
//do an active thing..
} else { // Else, (after doing the checks) the state is non-active..
// do a non-active thing..
}
}
You'll need to fill out the readState() function and install LC_baseTools from the IDE library manager to try it.