
Originally Posted by
HenrikOlsson
Hi Jaco,
I haven't looked into your code very deeply but here's an idea that might work.
Have a "counter" variable that you increment in each of the states where you have movement but not yet detected "the other" switch.
Figure out the magic number that matches ~20 seconds and if the "counter" ever reaches that number you abort the whole thing. When you go from a state of movement but no switch to a state where you detect a s switch you reset the "counter".
The timing may not be super accurate depending on how long your various subroutines takes but for a "simple timeout" it may suffice?
/Henrik.
Bookmarks