// use the FastLED library (someone's pre-written code)
#include <FastLED.h>
// set how many LEDs there are and the data pin.
const int NUM_LEDS = 30;
const int DATA_PIN = 6;
// this creates an array to reference our LEDs
CRGB leds[NUM_LEDS];
void setup() {
// tells the FastLED code e.g. what LEDs we are using, the data pin
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
// limit the strip's draw to 400mA at 5v
FastLED.setMaxPowerInVoltsAndMilliamps(5, 400);
// turns the brightness down (so my eyes don't hurt)
FastLED.setBrightness(8);
pinMode(2, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(2) == LOW){
for (int light=0; light<15; light+= 2){
leds[light] = CRGB::Green;
leds[29 - light] = CRGB::Red;
FastLED.show();
delay(550);
}
for(int light=1; light<30; light+= 2 ){
leds[light] = CRGB::Red;
leds[29 - light] = CRGB::Green;
FastLED.show();
delay(250);
}
for (int light=0; light<30; light++){
leds[light] = CRGB::Black;
}
FastLED.show();
delay(100);
for(int light=0; light<30; light+= 2){
leds[light] = CRGB::DeepPink;
FastLED.show();
delay(250);
}
for(int light=0; light<30; light+= 3){
leds[light] = CRGB::White;
FastLED.show();
delay(250);
}
for(int light=0; light<30; light++){
leds[light].setRGB(random(256), random(256), random(256));
FastLED.show();
delay(250);
}
for (int light=0; light<30; light++){
leds[light] = CRGB::Black;
}
FastLED.show();
delay(100);
for(int light=11; light<19; light++){
leds[light] = CRGB::Blue;
FastLED.show();
}
for(int light=0; light<10; light++){
leds[light] = CRGB::Red;
FastLED.show();
delay(300);
}
for( int light=0; light<10; light++){
leds[29-light] = CRGB::Green;
FastLED.show();
delay(300);
}
for(int light=0; light<30; light++){
leds[light] = CRGB::Cyan;
FastLED.show();
}
}
}
void lightsOff(){
for (int light=0; light<30; light++){
leds[light] = CRGB::Black;
}
FastLED.show();
}