// 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 = 3;
const int BTN_PIN = 2;
// 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() {
if (digitalRead (2) == LOW){
for (int light= 0; light <30; light +=2) {
leds[light] = CRGB::Red;;
leds[29-light] = CRGB::Orange;;
leds[1+light] = CRGB::Orange;;
leds[28-light] = CRGB::Green;;
FastLED.show();
delay(550);
}
for (int light= 0; light <30; light +=2) {
leds[light] = CRGB::Orange;;
leds[29-light] = CRGB::Green;;
leds[1+light] = CRGB::Red;;
leds[28-light] = CRGB::Orange;;
FastLED.show();
delay(225);
}
for (int light= 0; light <30; light +=2) {
leds[light].setRGB(random(255),random(255),random(255));
leds[29-light].setRGB(random(255),random(255),random(255));
FastLED.show();
delay(550);
}
for (int light = 30; light >= 0; light--) {
leds[light] = CRGB::Black;;
FastLED.show();
}
for (int light= 0; light < 30; light+=2) {
leds[29-light] = CRGB::Red;;
leds[light].setRGB(random(255),random(255),random(255));
FastLED.show();
delay(225);
}
for (int light= 30; light >= 0; light-=2) {
leds[29-light] = CRGB::Orange;;
leds[light].setRGB(random(255),random(255),random(255));
FastLED.show();
delay(112.5);
}
for (int light= 30; light >= 0; light--) {
leds[light] = CRGB::White;;
FastLED.show();
delay(225);
}
for (int light= 0; light <30; light +=2) {
leds[light] = CRGB::Orange;;
leds[29-light] = CRGB::Green;;
leds[1+light] = CRGB::Red;;
leds[28-light] = CRGB::Orange;;
FastLED.show();
delay(225);
}
}
}
void lightsOff(){
for (int light= 0; light <30; light +=2) {
leds[light] = CRGB::Black;;
leds[29-light] = CRGB::Black;;
FastLED.show();
delay(225);
}
}