Timeline for How can I interrupt a delay() when a button is pressed?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 5, 2020 at 9:41 | comment | added | Kwasmich | You can if you handle your button press in a pin change interrupt handler. But still it is bad practice to use delay(). The only legit use is a timed sequence where you are not doing anything else. | |
Feb 5, 2020 at 8:08 | vote | accept | Gabe Ruiz | ||
Jan 8, 2020 at 22:52 | comment | added | Duncan C |
You asked "How can I interrupt a delay() when a button is pressed?" The short answer is that you can't. delay() is a blocking function. It can't be interrupted. You need to refactor your code as others have suggested.
|
|
Jan 8, 2020 at 9:35 | answer | added | Michel Keijzers | timeline score: 1 | |
Jan 8, 2020 at 8:01 | comment | added | Rozona Zoro | I took a look to your code in Github. I think you also need to debounce for button | |
Jan 8, 2020 at 7:58 | comment | added | Rozona Zoro | Use timestamp instead of delay(), see Blink Without Delay example | |
Jan 8, 2020 at 7:52 | comment | added | jsotola |
look at the blink without delay example sketch
|
|
Jan 8, 2020 at 7:40 | history | asked | Gabe Ruiz | CC BY-SA 4.0 |