Can't get shorter than that???
That's true, though I am wondering : why detach ?
Anyway, here is the Holy Book of ATMega328 Interrupts !
Eric
Can't get shorter than that???
That's true, though I am wondering : why detach ?
Anyway, here is the Holy Book of ATMega328 Interrupts !
I will have to read it.
Why detach?
I usually detach an interrupt until the boolean value has been changed back to its original state.
Just a really simple example that does not block interrupts like delay() does.
volatile bool flag = false; void setup() { attachInterrupt(digitalPinToInterrupt(2), changeFlag, CHANGE); } void loop() { for(,,){ // do anything you want to while flag has not been set // anything here runs for ever until the interrupt is fired if(flag){ flag = !flag; break; } } } void changeFlag(){ flag = !flag; //toggle flag from false to true }
Would it be possible to create another case/state for a complete and total reset of the system?
What happens if you press the reset button on the Arduino?
Maybe write your own delay routine that aborts when a button is pressed?
I will give it some thought with your current source code in mind. In the meantime a challenge for all coders to come up with the best solution 🙂