Wait for input

Hi there,

I have small programming problem which is quite easy to solve i guess - I just don't know how. In fact i want to programm a menu through which is navigated with an rotary encoder. This menu shall be in a subfunction which is activated by a button.

Now my problem is, that I don't know how a "wait order" is implemented:
The idea is, that the programm waits for maybe 10 seconds to get an input signal (which is then once again the rotary encoder for choosing an option or the button then to select it) or, if no signal is detected, then jumps back to the main function.

I guess i can't use the delay order since then the whole programm is being made to wait and it won't accept any input signals in the mean time.

I guess i can't use the delay order since then the whole programm is being made to wait and it won't accept any input signals in the mean time.

You guess correctly. You can implement a while loop, and use millis().

unsigned long startTime = millis();
while(millis() - startTime < interval)
{
   // check for input. Break if found
}
// When we get here, either there was input or the time expired.

Thank you. That helped a lot. :wink: