#include <FastLED.h>
#define LED_PIN 2
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 80
CRGB leds[NUM_LEDS];
//PALETTE
DEFINE_GRADIENT_PALETTE( greenblue_gp ) {
0, 0, 194, 255, //light blue
46, 3, 0, 246, //dark blue
176, 55, 222, 70, //bright green
255, 0, 194, 255 //light blue
};
DEFINE_GRADIENT_PALETTE( orangepink_gp ) {
0, 255, 100, 0, //orange
90, 255, 0, 255, //magenta
150, 255, 100, 0, //orange
255, 255, 100, 0 //orange
};
DEFINE_GRADIENT_PALETTE( browngreen_gp ) {
0, 6, 255, 0, //green
71, 0, 255, 153, //bluegreen
122, 200, 200, 200, //gray
181, 110, 61, 6, //brown
255, 6, 255, 0 //green
};
FL_PROGMEM TProgmemRGBGradientPalettePtr const palettes[] = {
greenblue_gp,
orangepink_gp,
browngreen_gp,
Rainbow_gp
};
size_t const sz_palettes = sizeof(palettes) / sizeof(*palettes);
// two palettes to hold expanded gradient palettes, to be blended between
// set the B palette to the Rainbow palette, to fade in at power up
CRGBPalette16 palA, palB = palettes[sz_palettes - 1];
void setup() {
Serial.begin(115200);
FastLED.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds, NUM_LEDS);
}
// return a random number which is different each time
uint8_t choose(uint8_t const choices) {
static uint8_t last_choice = 0;
uint8_t res;
do {
res = random8(choices);
} while (res == last_choice);
last_choice = res;
return res;
}
void scannerAnimation(int durationMs, CRGB color) {
unsigned long startTime = millis();
int scannerWidth = 5; // Largeur du scanner
while (millis() - startTime < durationMs) {
for (int i = 0; i < NUM_LEDS + scannerWidth; i++) {
for (int j = 0; j < NUM_LEDS; j++) {
if (j >= i && j < i + scannerWidth) {
leds[j] = color;
} else {
leds[j] = CRGB::Black;
}
}
FastLED.show();
delay(30);
}
}
}
void loop() {
for(int i=0;i<NUM_LEDS;i++)
{
leds[i]=CRGB(random(255),random(255),random(255));
}
FastLED.show();
Serial.println(FastLED.getFPS());
}