r/FastLED • u/madmusician • Oct 22 '25
Support Code running in sequence, not simultaneously
I'm missing something in my code, as I am relatively new to this type of programming and looking at the Wiki I am either not finding what I need or misreading what I need as something else.
For reference for my project, there are six individual LED strands of differing amounts of LEDs (60 or less) that are in six different data channels on my knockoff nano. I confirmed that each six can work mirroring off each other, and by changing which variable I plug in with commenting out the rest to have just one strand running at a time.... but now I am trying to be able to program each strip with its proper amount of LEDs with a chase effect (all the LEDs lit at like, 10% brightness all the time and the "chase" itself being 100% brightness... Which will be added later, once I figure out how to do that too haha).. So right now it is single threading it, instead of running each "For" statement at the same time. It makes sense as it is obviously going top to bottom, one line at a time, but I am unsure how to fix that to have each channel be independently ran all at the same time.
Any help at all would be greatly appareciated!
include <FastLED.h>
define NUM_LEDS_1 58
define NUM_LEDS_2 58
define NUM_LEDS_3 58
define NUM_LEDS_4 58
define NUM_LEDS_5 58
define NUM_LEDS_6 58
CRGB StringOne[NUM_LEDS_1]; CRGB StringTwo[NUM_LEDS_2]; CRGB StringThree[NUM_LEDS_3]; CRGB StringFour[NUM_LEDS_4]; CRGB StringFive[NUM_LEDS_5]; CRGB StringSix[NUM_LEDS_6];
void setup() { FastLED.addLeds<NEOPIXEL, 2>(StringOne, NUM_LEDS_1); FastLED.addLeds<NEOPIXEL, 3>(StringTwo, NUM_LEDS_2); FastLED.addLeds<NEOPIXEL, 4>(StringThree, NUM_LEDS_3); FastLED.addLeds<NEOPIXEL, 5>(StringFour, NUM_LEDS_4); FastLED.addLeds<NEOPIXEL, 6>(StringFive, NUM_LEDS_5); FastLED.addLeds<NEOPIXEL, 7>(StringSix, NUM_LEDS_6); }
void loop() { for(int i = 0; i < NUM_LEDS_1; i++) { StringOne[i] = CRGB::Green;
FastLED.show(); StringOne[i] = CRGB::Black; delay(40); }
for(int i = 0; i < NUM_LEDS_2; i++) { StringTwo[i] = CRGB::Green;
FastLED.show(); StringTwo[i] = CRGB::Black; delay(40); }
for(int i = 0; i < NUM_LEDS_3; i++) { StringThree[i] = CRGB::Green;
FastLED.show(); StringThree[i] = CRGB::Black; delay(40); }
for(int i = 0; i < NUM_LEDS_4; i++) { StringFour[i] = CRGB::Green;
FastLED.show(); StringFour[i] = CRGB::Black; delay(40); }
for(int i = 0; i < NUM_LEDS_5; i++) { StringFive[i] = CRGB::Green;
FastLED.show(); StringFive[i] = CRGB::Black; delay(40); }
for(int i = 0; i < NUM_LEDS_6; i++) { StringSix[i] = CRGB::Green;
FastLED.show(); StringSix[i] = CRGB::Black; delay(40); } }
View all comments
Show parent comment
1
u/dr-steve Oct 23 '25
If the strands have different lengths, do you plan to keep them in sync (assuming that that is what you want to do)?
You might do something like this (note: coding off the top of my head, but I do a lot of timed ops with FastLED; also, I don't use the EVERY_N_MILLISECONDS. I use TaskManager, a lightweight multitasking system I wrote for nanos around 10 years ago; see github.com/drsteveplatt for details. Works well on ESPs (and Megas; haven't tested it elsewhere); allows multitask communication and synchronization, timing, multinode operations (I've had 40 ESPs working well together on a large art installation), etc..
But... I can work with EVERY_N_MILLISECONDS for simpler tasks
Reminder: code is rough and untested, but do you see where I am going?
Oh, if you want to see some of the time-based installations I've done using LEDS and FastLED, check out youtube.com/@amuseyeux
Edit: typo in code.