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/Marmilicious [Marc Miller] Oct 30 '25
I had a bad cold and this got lost in the chaos. Getting back to you... here's a few ideas/links related to mirroring your pixel data. It could be as simple as using one or more for loops to copy the pixel data from one CRGB array to others. In the loop you can do something like:
You could try to add an offset to the copy (and use % [modulo] to keep things in bound of the array). Be very careful when writing data to a CRGB array to make sure you don't try to write to a pixel past the end of the array.
Here's some links to go with the above ideas. This demos using modulo to stay in bounds of the CRGB array:
https://github.com/marmilicious/FastLED_examples/blob/master/three_moving_colors.ino
This demos using memmove8 to copy data from one array to another. Using memmove8 would be a very easy way to copy data from leds1 to other arrays, AND offset the data at the same time if desired. Just be careful to stay in bounds of the array.
https://github.com/marmilicious/FastLED_examples/blob/master/memmove8_example.ino