// use the FastLED library (someone's pre-written code)
#include <FastLED.h>
const int NUM_LEDS = 30;
const int DATA_PIN = 12;
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(5,400);
FastLED.setBrightness(8);
pinMode(11, INPUT_PULLUP);
}
void loop() {
if(digitalRead(11) == LOW){
startLights();
}
}
void startLights(){
for(int i=0; i<30; i++){
leds[14+i] = CRGB::Red;
leds[15-i] = CRGB::GreenYellow;
}
FastLED.show();
delay(500);
for(int i=0; i<30; i++){
leds[random(30)].setRGB(127*random(3), 127*random(3), 127*random(3));
}
FastLED.show();
delay(500);
for(int i=30; i<2; i++){
for(int i=random(30); i<30; i++){
leds[i] = CRGB::White;
leds[30-i] = CRGB::White;
leds[i-1] = CRGB::Black;
}
FastLED.show();
delay(500);
}
for(int i=0; i<30; i++){
leds[i] = CRGB::Purple;
leds[i-1] = CRGB::Black;
FastLED.show();
delay(250);
leds[i] = CRGB::Black;
for(int i=0; i<30; i++){
leds[30-i] = CRGB::Purple;
leds[1-i] = CRGB::Black;
FastLED.show();
delay(250);
leds[i] = CRGB::Black;
}
FastLED.show();
delay(500);
}
for(int i=0; i<30; i++){
leds[i] = CRGB::Cyan;
FastLED.show();
delay(200);
}
for(int i=0; i<30; i++){
leds[i].setRGB(127*random(3), 127*random(3), 127*random(3));
}
for(int i=0; i<5; i++){
leds[i] = CRGB::Black;
}
FastLED.show();
delay(500);
}