// LED STRIP EXAMPLE
// can use this to write code at home
// -----------------------------------------
// 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() {
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::White;
leds[light + 1] = CRGB::Green;
leds[light + 2] = CRGB::Red;
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Red;
leds[light + 1] = CRGB::White;
leds[light + 2] = CRGB::Green;
}
FastLED.show();
delay(420);
if (digitalRead (2) == LOW) {
startLight();
}
}
void startLight() {
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Green;
leds[light + 1] = CRGB::Cyan;
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Cyan;
leds[light + 1] = CRGB::Green;
}
FastLED.show();
delay(420);
for (int light = 0; light < 15; light++) {
leds[light] = CRGB::Yellow;
leds[29 - light].setRGB(255, 0, 188);
FastLED.show();
delay(420);
}
for (int light = 0; light < 10; light++) {
leds[light] = CRGB::Green;
leds[10 + light] = CRGB::White;
leds[20 + light] = CRGB::Red;
FastLED.show();
delay(420);
}
for (int light = 9; light >= 0; light--) {
leds[light].setRGB(255, 0, 188);
leds[10 + light] = CRGB::Blue;
leds[20 + light] = CRGB::Yellow;
FastLED.show();
delay(420);
}
for (int light = 14; light > -1; light--) {
leds[light] = CRGB::Cyan;
leds[29 - light] = CRGB::Green;
FastLED.show();
delay(400);
}
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Red;
leds[light + 1] = CRGB::Blue;
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Blue;
leds[light + 1] = CRGB::Red;
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light].setRGB(255, 0, 188);
leds[light + 1].setRGB(255, 162, 0);
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light].setRGB(255, 162, 0);
leds[light + 1].setRGB(255, 0, 188);
}
FastLED.show();
delay(420);
leds[random(15)] = CRGB::Yellow;
FastLED.show();
delay(440);
leds[random(20)] = CRGB::Red;
FastLED.show();
delay(440);
leds[random(25)] = CRGB::Blue;
FastLED.show();
delay(440);
leds[random(30)] = CRGB::White;
FastLED.show();
delay(440);
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Yellow;
leds[light + 1] = CRGB::Cyan;
leds[light + 2] = CRGB::Red;
leds[light + 3] = CRGB::Blue;
}
FastLED.show();
delay(420);
for (int light = 0; light < 30; light += 2) {
leds[light] = CRGB::Red;
leds[light + 1] = CRGB::Yellow;
leds[light + 2] = CRGB::Blue;
leds[light + 3] = CRGB::Cyan;
}
FastLED.show();
delay(420);
}