Here is my idea for my project:
- LED pin 11, 12 and 13 will flash as a sequence when the code starts running
- When a button is pressed, it will light up and stay on; and LED pin 11, 12 and 13 will stop flashing as a sequence.
- When a button is pressed again, the light will turn off and LED pin 11, 12 and 13 will start flashing as a sequence again.
If you look at my code, I have initially used 3 functions which I have commented as “updateLed1FlashState()”, "updateLed2Flashstate() and “updateLed3FlashState()” to create a sequence. I had a problem that the flashing sequence would not stop when either buttons is being pressed.
I then further thought it might be solved if I use a for loop for my flashing sequence, and now it is not reading if my button is being pressed or not.
May I ask if any of you would suggest which part of my logic is wrong please?
test6.ino (7.34 KB)