WS2812B Fastled Theater chase

The theater chase from tweaking4all seems to be like this :

  • One LED of each N LEDs (meaning the other N-1 are off)
  • Shift every LEDs by one to the right: do the shift N-1 times (due to periodicity)
    (I hope I explain clearly, I'm not native english speaker)

This can be done by playing with modulo (the % operator)

void setLEDs (int K,int N) {
  for (int i=0;i<NUM_LEDS;i++) {
    if (i%N == K)   leds[i].setRGB (127, 0, 0);  // set red LED
  }
}

This function should be called in the loop :

void loop() {
  FastLED.clear();
  for  (int i=0;i<N;i++) {
    setLEDs (i,N); }
  FastLED.show();
  delay (50);
}

The setup changes to

void setup() {
  delay (1000);
  LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
}

and you need to declare the period before the setup:
N = 5;
for example.

Try it ! :slight_smile: