Author Options:

Arduino uno: How to switch flashing patterns with a button Answered

Hi everyone

I'm still learning how to use an arduino uno and if anyone could help me on this it would be greatly appreciated.

Question: How do you switch between different flashing patterns (sorry I don't know terminology) on 4 LEDs with a single push button in an arduino uno?

Extra: My aim is to program a bike light using an arduino uno. I'm planning to have 4 LEDs and a single push button. When the button is first pushed, the 4 LEDs stay turned on, and when pushed again they flash, when pushed again they change pattern e.g. scroll and so on until it finally turns off after the final push of the button.

I have been able to test several loops but they just continue forever like expected. If anyone could help me with what code to use to switch between the flashing patterns that would be greatly appreciated.

Thank you!


The forums are retiring in 2021 and are now closed for new topics and comments.