How to interrupt a code after delay I have a functionality on my mega 2560 to connect with other devices. Sometimes, devices can't answer. I don't want to wait for a longwhile. So, how can I interrupt the chunk of program after the specific amount of time? 

My code for receiving messages is:

while (!(UCSR1A &amp; (1&lt;&lt;RXC1)));


so, millis can't solve my problem because I haven't ability to check for conditional loops like that

if(currentMillis - previousMillis &gt; interval) {
OMG, I was stupid. I can just place millis in this while condition.