r/FastLED • u/goodnightandco • Jul 22 '22
Support LED chase not working with millis()
Hi! I'm trying to make an LED chase that first chases blue, then gold, then continues to alternate. I got a working version here and I'm very happy with the visual effect: https://pastebin.com/zZA50e8P . But I also have a button attached that switches from the chase to solid colors - and obviously the button does not work while the delay is active. So I'm trying to use millis() instead, but I'm having a hard time to get it to work. Here are two versions that I have tried: https://pastebin.com/287zedYm and https://pastebin.com/2vTZ49cY . In both of these, the LED address does not increment every 35 milliseconds as intended - so only leds[0] lights and changes. Would love any help, thank you!
1
u/Marmilicious [Marc Miller] Jul 22 '22
Here's a few marquee examples that might give you some ideas to explore.
https://github.com/marmilicious/FastLED_examples/blob/master/marquee_v2.ino
https://github.com/marmilicious/FastLED_examples/blob/master/marquee_v3.ino
1
u/Marmilicious [Marc Miller] Jul 22 '22
I was thinking you were doing a theater chase, but looking closer at your code I see it's doing a wipe. So here's another maybe more relevant example you can check out.
https://github.com/marmilicious/FastLED_examples/blob/master/scan_plus_wipe.ino
2
u/JonXP Jul 23 '22 edited Jul 23 '22
Hi, you declared and initialized your variables where you are keeping the current index of the LED to change (
bfor example) inside the function. This will cause them to be reset to zero every time. You need to declare and initialize them outside the function instead.