#include <FastLED.h>
//FastLED lib in combination with ESP32 here at Wokwi crashes
#define NUM_LEDS 48 // if the number is exactly 8 or a multiple of 8. The first call of
// FastLED.show() in loop() stops the whole sketch.
// For one led-ring with 16 LED you can use 1 to 7 or 9 to 15 or 17 ...
// but NUM_LEDS = 8, 16, 24, 32, 40 or 48 ... let the sketch crash ....
#define DATA_PIN 5
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(57600);
Serial.println("resetting");
FastLED.addLeds<WS2812B,DATA_PIN,GRB>(leds,NUM_LEDS);
//FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.setBrightness(200);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].fadeToBlackBy(80); } }
void loop() {
// put your main code here, to run repeatedly:
for(int i = 0; i < NUM_LEDS-1; i++) { // NUM_LEDS-1 as we use [i+1] in the loop()
leds[i+1] = CRGB::Blue; // Otherwise this index would become equal to NUM_LED
// which is out-of-range of leds[NUM_LEDS] (0 ... NUM_LEDS-1)
leds[i] = CRGB::Yellow;
Serial.println(i);
FastLED.show();
fadeall();
delay(200);
}
}