#include <FastLED.h>
#define NUM_STRIPS 5
#define NUM_LEDS_PER_STRIP 16
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS
#define BRIGHTNESS 255 // 255 is full brightness, 128 is half
#define MIN_BRIGHTNESS 8 // watch the power!
#define MAX_BRIGHTNESS 255 // watch the power!
CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
//reorder LEDs sequence
int db[] = {0,15,1,14,2,13,3,12,4,11,5,10,6,9,7,8,
16,32,31,47,17,33,30,46,18,34,29,45,19,35,28,44,
20,36,27,43,21,37,26,42,22,38,25,41,23,39,24,40,
48,64,63,79,49,65,62,78,50,66,61,77,51,67,60,76,
52,68,59,75,53,69,58,74,54,70,57,73,55,71,56,72
};
void setup() {
delay( 2000 ); // power-up safety delay
FastLED.addLeds<WS2812B, 3, GRB>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
//set rainbow background
fill_rainbow(leds, NUM_LEDS, 0, 9);
FastLED.show();
delay(1000);
}
void loop() {
//clear background
fill_solid(leds, NUM_LEDS, CRGB::Black);
for(int n = 0; n < NUM_LEDS; n++) {
meteorRain(10, 32, true, 30, n);
leds[db[n]] = CHSV(n*9,255,255);
FastLED.show();
}
}
void meteorRain(byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay, int n) {
//for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
//change the above loop for reversed direction
for(int i = NUM_LEDS+NUM_LEDS; i > n; i--) {
// fade brightness LEDs one step
// j=n fade less by each step; j=0 fade all in each step
for(int j=n; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
fadeToBlack(j, meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
leds[db[i-j]] = CHSV((i-j)*9,255,255);
}
}
FastLED.show();
delay(SpeedDelay);
}
}
void fadeToBlack(int ledNo, byte fadeValue) {
leds[db[ledNo]].fadeToBlackBy( fadeValue );
}