depending on what else you want to do in your code staying inside a ISR indeed blocks everything else. I'm not familiar with the real inner details of interrupts on Atmega328 (nor any other chips). There might be a priority that an interrupt of an even higher priority can interrupt a lower-priority interrupt. But usually as long as you are inside an ISR and something else would like to react on an interrupt-event like
- receiving serial data,
- signal-change on a I2C-bus
- signal change on a SPI-bus does not occur.
Effect:
your code is missing signals that normally would invoke an interrupt.
And this is the reason why you should be back from in interrupt as soon as possible
to keep everything else working.
creating servopulses is based on a timer-interrupt. Not sure if this servo-pulse-timer-interrupt gets affected by a long execution-time of your ISR.
This 50 millisecond pulse. Would your device malfunction if the pulse would be 100 millisecons or 250 milliseconds long?
How fast does your void loop()
loop?
if it is fast enough you would simply set a flag inside your ISR and the main-code would check for flag set. if flag is set switch HIGH and store a snapshot of time
if your loop () needs 100 milliseconds anyway just switch off with the next iteration.
else if your loop() loops at 20 milliseconds check
if (millis() - StartOfPulse) >= 50) {
switch-off
}
You have some delays() for blinking inside your loop() and functions do have delay()
If all these delays() get replaced by non-blocking timing which is very easy and the most classical thing for non-blocking timing
I estimate that your loop runs very fast.
just in case I had not yet posted a link to this tutorial
best regards Stefan