// use the FastLED library (someone's pre-written code)
#include <FastLED.h>
// set how many LEDs there are and the data pin.
const int numLeds = 30;
const int ledStripPin = 6;
// this creates an array to reference our LEDs
CRGB leds[numLeds];
void setup() {
// tells the FastLED code e.g. what LEDs we are using, the data pin
FastLED.addLeds<NEOPIXEL, ledStripPin>(leds, numLeds);
// 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){
lightshow();
}
}
void lightshow(){
for(int light=0; light< 190; light++){//buzz part of the song
turnBlack();
delay(10);
turnBlue();
delay(10);
}
turnLime();// turns the colour lime
delay(970);
turnRed();// turns the colour red
delay(970);
turnPurple();// turns the colour purple
delay(970);
turnYellow();// turns the colour yellow
delay(955);
windUpWhite();// turns the yellow leds into white
delay(409);
for(int light=0; light<2; light++){
turnAllRandom();// random colours that match beat
delay(475);
turnBeat();
delay(475);
}
windUpWhite();
delay(409);
turnAllBlack();// make all black
delay(489);
}
void turnBlack() {//working buzzes to match the start of song
for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Black;
}
FastLED.show();
}
void turnBlue() {//working buzzes to match the start of song
for(int light=0; light<numLeds; light++){
leds[light] = CRGB::Blue;
}
FastLED.show();
}
void turnLime(){//this code is working
for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Lime;
}
FastLED.show();
}
void turnRed()//this code works
{for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Red;
}
FastLED.show();
}
void turnPurple(){// this code works
for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Purple;
}
FastLED.show();
}
void turnYellow(){// this code works
for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Yellow;
}
FastLED.show();
}
void windUpWhite() {
for (int light = 0; light < 4; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 26; light < 30; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 4; light < 8; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 22; light < 26; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 8; light < 12; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 18; light < 22; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 12; light < 16; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
for (int light = 16; light < 18; light++) {
leds[light] = CRGB::White;
}
FastLED.show();
delay(489);
}
void turnAllRandom(){//this code somewhat works
for (int light =0; light <numLeds; light++){
int red= random (0,255);
int blue= random(0,255);
int green= random(0,255);
leds[light].setRGB(red,green,blue);
}
FastLED.show();
// delay(489);
}
void turnBeat(){// this code works but want to change
for (int light=0; light<numLeds; light++){
leds[light] = CRGB::Blue;
}
FastLED.show();
delay(489);
}
void turnAllBlack() {
for(int light=0; light<numLeds; light++){
leds[light] = CRGB::Black;
}
FastLED.show();
delay(489);
}