I am pretty new to Arduino. One of my projects are making LEDs flash in many patterns with the Arduino programmed to be the controller of the fairy lights. I have written 2 functions for the patterns and I have made a counter using a push-button to switch between them, but my counter can't run if one of my pattern functions is still running and can't switch to the next pattern function due to the long delays in it. Is there any workaround to this?
Hi! Welcome to the Forum.
Take a look in the basic example "Blink without delay" and the use of millis()
instead of delay()
. "Arduino non blocking code" in Google can give you some insights.
1 Like
Interesting. Never thought of using millis(). I would give it a try. Thank you for your help.
There might be another workaround using interrupts, but that does depend on the code you are using, and is not the preferred way of solving it. The method suggested by @Brazilino is the best option.
- Show us.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.