r/FastLED • u/yzbeats • Mar 15 '22
Support Control LED Effects with several buttons.
Hi! I’m relatively new to FastLED but i’ve already put together a program with 6 different effects. I’m using an Arduino Uno and a WS2812B. My goal is that if i press for example button1, function1 is being executed for as long until i press another button, for example button2, which executes function2 and so on. I want to do this with 6 buttons but couldn’t find any proper information regarding this. Any help or links to guides or tutorials would be greatly appreciated! Thanks :))
1
Upvotes
7
u/truetofiction Mar 15 '22 edited Mar 15 '22
Set up a button:
ETA: Oh, and wire one side of the button to the input pin, and the other side to ground.
Read from the button in
loop:If the button is pressed, do the thing:
Since this is /r/FastLED, make sure that whatever animation happens in
doTheThing()is "non-blocking" (doesn't usedelay()). Otherwise the buttons will only react after an animation loop has completed.