Arduino FastLED Con Micro
Arduino FastLED Con Micro
h>
#include "FastLED.h"
long randomNumber;
// Mode enumeration - if you want to add additional party or colour modes, add them
here; you'll need to map some IR codes to them later;
// and add the modes into the main switch loop
enum Mode { CLOUD,OFF};
Mode mode = CLOUD;
Mode lastMode = CLOUD;
void setup() {
// this line sets the LED strip type - refer fastLED documeantion for more
details [Link]
[Link]<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
// starts the audio samples array at volume 15.
memset(vol, 15, sizeof(vol));
[Link](115200);
randomSeed(analogRead(A1));
}
void loop() {
}
void detect_thunder() {
total = 0;
for(int i=0; i<SAMPLES; i++) {
total += vol[i];
}
average = (total/SAMPLES)+2;
if(n>average){
[Link]("TRIGGERED");
reset();
case 1:
thunderburst();
delay(random(10,500));
[Link]("Thunderburst");
break;
case 2:
rolling();
[Link]("Rolling");
break;
case 3:
crack();
delay(random(50,250));
[Link]("Crack");
break;
}
}
}
}
void rolling(){
// a simple method where we go through every LED with 1/10 chance
// of being turned on, up to 10 times, with a random delay wbetween each time
for(int r=0;r<random(2,10);r++){
//iterate through every LED
for(int i=0;i<NUM_LEDS;i++){
if(random(0,100)>90){
// leds[i] = CHSV(randomNumber, randomNumber, randomNumber);
}
else{
//dont need reset as we're blacking out other LEDs her
leds[i] = CHSV( 0, 0, 0);
}
}
[Link]();
delay(random(5,100));
reset();
}
}
void crack(){
//turn everything white briefly
for(int i=0;i<NUM_LEDS;i++) {
// leds[i] = CHSV(randomNumber, randomNumber, randomNumber);
leds[i] = CHSV(0, 0, 255);
}
[Link]();
delay(random(10,100));
reset();
}
void thunderburst(){
[Link]();
//stay illuminated for a set time
delay(random(10,50));
reset();
delay(random(10,50));
}