I have pieced together some code that enables a chunk of 5 LEDS to flow from one end of a strip to the other 5 times (j) upon pressing a button. The colour of the shown LEDS changes as it passes along the strip through the zones of color. The color zones are defined in setup and called upon in the loop.
So far it works great, although id like to be able to send another chunk of LEDS through the strip to chase the other. Lets say when the first chunk of LEDS reaches a certain number, the next chunk starts from 0, maybe even add multiple chunks.
I’m pretty sure I have to add another FOR loop within the main loop, but everything I have tried so far has has erratic results.
Any help with this would be appreciated.
Thanks,
N
(FastLED ver3.1.3, Arduino 1.6.5, Uno, Mac)
I have written something similar. The way I found to this easily was to actually write it as object orientation code. I can encapsulate all the variables needed for each snake inside each snake object, so the outer for loop just calls move on each snake in turn per frame
Should I just be counting once at the start of the loop utilizing this counter for everything, just not sure where to start, would I have to use a new integer for the next “snake”?
Also is there a better way to show the LEDS from 0-5 instead of this:
leds[i] = ledsTemp [i];
leds[i+1] = ledsTemp [i+1];
leds[i+2] = ledsTemp [i+2];
leds[i+3] = ledsTemp [i+3];
leds[i+4] = ledsTemp [i+4];
the issue I’m having now seem to be with counting / moving the pixels. Could someone tell me why the code only works with NUM_LEDS-11in the second for loop.
Even then the code doesn’t complete the last loop i.e. there are still pixels on at the end of the show.
I’d like to roll on the pixels and have them roll off the end of the strip, I tried using negative values for “i” but didn’t work.