This is an addition to esoterik's answer.
Most of the times, that people try to use delay()
inside an ISR it is a poor design choice to even use it in a general way, that will lead to the described problems (waiting forever or missing other interrupts). delay()
is a simple function mainly for beginners with very simple programs. It is a simple starting point. Mostly the use of it in any program is not a good choice, since you are busy waiting without being able to do something else (like responding to user input). There are better ways, involving millis()
itself, that keep your program extendable (so that, if you want to add a functionality, this will not be blocked by the first part of the code). And when your program reaches the complexity of using own ISRs, you should avoid delay()
, unless you really know, what you are doing.
IMO at some (rather early) point, every Arduino programmer has to learn how to use millis()
to do timed code execution. You can look at the BlinkWithoutDelay
example, that comes with the Arduino IDE.