#include "FastLED.h"
#define NUM_LEDS 300
CRGB leds[NUM_LEDS];
#define PIN 3
#define BRIGHTNESS 200
int8_t inc = 0;
DEFINE_GRADIENT_PALETTE(RainPal) {
0, 182, 203, 238,
64, 165, 190, 231,
128, 142, 174, 227,
192, 128, 160, 214,
255, 104, 142, 206
};
DEFINE_GRADIENT_PALETTE(SnowPal) {
0, 207, 246, 251,
13, 214, 239, 254,
38, 189, 222, 255,
69, 201, 215, 255,
102, 197, 203, 253,
140, 177, 190, 255,
179, 188, 197, 246,
204, 189, 222, 255,
230, 214, 239, 254,
255, 207, 246, 251
};
CRGBPalette16 palette_rain = RainPal;
CRGBPalette16 palette_snow = SnowPal;
void setup()
{
delay(1000); // 1 second delay for recovery
FastLED.addLeds<WS2813, PIN, GRB>(leds, NUM_LEDS); //.setCorrection( TypicalSMD5050 ); // tell FastLED about the LED strip configuration
FastLED.setBrightness(BRIGHTNESS); // set master brightness control
// fill_solid(leds, NUM_LEDS, CRGB::Blue);
}
void loop() {
//Rain(50);
Snow();
FastLED.show();
}
void Rain(int intensity) {
EVERY_N_MILLISECONDS(intensity) {
leds[random16(0, NUM_LEDS - 1)] = ColorFromPalette(palette_rain, random8(0, 255));
}
fadeToBlackBy(leds, NUM_LEDS, 1);
}
void Snow() {
EVERY_N_MILLISECONDS(100){
leds[0] = ColorFromPalette(palette_snow, inc, BRIGHTNESS);
for (int i = NUM_LEDS-1; i > 0; i--) {
leds[i] = leds[i-1];
}
inc++;
}
}