// https://www.reddit.com/r/FastLED/comments/1oczzf8/code_running_in_sequence_not_simultaneously/
#include <FastLED.h>
// Set the length of each strip
CRGBArray<58> StringOne;
CRGBArray<57> StringTwo;
CRGBArray<56> StringThree;
CRGBArray<55> StringFour;
CRGBArray<54> StringFive;
CRGBArray<53> StringSix;
// An array of those strips, for ease of referring to them in loops and things
const CRGBSet strips[] = {StringOne, StringTwo, StringThree, StringFour, StringFive, StringSix};
void setup() {
FastLED.addLeds<NEOPIXEL, 2>(strips[0], strips[0].len);
FastLED.addLeds<NEOPIXEL, 3>(strips[1], strips[1].len);
FastLED.addLeds<NEOPIXEL, 4>(strips[2], strips[2].len);
FastLED.addLeds<NEOPIXEL, 5>(strips[3], strips[3].len);
FastLED.addLeds<NEOPIXEL, 6>(strips[4], strips[4].len);
FastLED.addLeds<NEOPIXEL, 7>(strips[5], strips[5].len);
}
void loop() {
// store the current position of the dot for each strip
static int pos[6];
// draw each strip's dot
int count = 0;
for (auto &strip: strips) {
strip.leds[pos[count++]] = CRGB::Green;
}
// Send the framebuffer to the LEDs at least once, and
// then send repeatedly until at least 20ms has elapsed
FastLED.delay(20);
// for each strip…
count = 0;
for (auto &strip: strips) {
// …dim every pixel of this strip
strip.fadeToBlackBy(16);
// and for each pixel on the current strip…
for (auto &pixel: strip) {
// …light very dim pixels with a background colour
if (pixel < CRGB(0, 32, 0))
pixel = CRGB(0, 32, 0);
}
// move this dot to the next position…
pos[count] += 1;
// …and wrap at the end of this strip
pos[count] %= strip.len;
count++;
}
}