If I have a delay of 1 second in my code and external interrupts, which takes precedence? I am pretty sure that interrupts do, but I am not sure. I know that at some point during the delay, the condition for the interrupt will be satisfied, but I DO NOT want the interrupt process to occur. If the delay takes precedence, then I am fine. If the interrupt takes precedence, then I was thinking something like:
detachInterrupt(8);
delay(1000);
//...At some later point in time...//
attachInterrupt(8, pulse, RISING);
I'd hate to do this because it would make my code somewhat more complex, because I would be reattaching the interrupt every loop.
A solution to my proposed problem is to make a new condition (using the full code):
if (digitalRead(13) = LOW) {
//loop//
} else {
delay(1);
if (digitalRead(13) = HIGH) {
delay(1000);
if (digitalRead(13) = LOW) {
attachInterrupt(8, pulse, RISING);
}
}
}
Finally, would a PWM keep running through the loop? The whole point of the loop is to stop the PWMs in the loop from running, but if they keep running during the delay, then it would defeat the point of making the delay like this. If PWMs keep running, I was thinking of TimerX.setCount(100);
inside the if statement (replacing the delay(1000);
and what follows it). That would freeze all PWMs.