#include <FastLED.h>
#define PIN_LEDS 5
#define NBR_LEDS 3
CRGB leds[NBR_LEDS];
const uint8_t teintes[] = {0, 43, 85, 127, 170, 213, 255};
const uint8_t nbTeintes = sizeof teintes;
void setup() {
FastLED.addLeds<WS2812B, PIN_LEDS, GRB >(leds, NBR_LEDS);
}
void loop() {
static size_t teinte = 0;
static uint8_t brightness = 0;
static bool incrementation = true;
fill_solid(leds, NBR_LEDS, CHSV(teintes[teinte], 255, brightness)); // 127 = vert, 255 totalement saturé
FastLED.show();
if (incrementation) {
if (brightness == 255) {
incrementation = false;
brightness = 254;
} else {
brightness++;
}
} else {
if (brightness == 0) {
incrementation = true;
brightness = 1;
teinte = (teinte + 1) % nbTeintes;
} else {
brightness--;
}
}
delay(1);
}