// ATTEMPT THREE
#include <FastLED.h>
#define NUM_LEDS 15
#define DATA_PIN 4
#define BUTTON 3
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
pinMode(BUTTON, INPUT_PULLUP);
}
void loop() {
if(digitalRead(BUTTON)==LOW){
unsigned long startTime = millis();
while(millis()-startTime < 7000){
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Red;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Green;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Blue;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Yellow;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Cyan;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Magenta;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Orange;
}
FastLED.show();
delay(1000);
}
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
FastLED.show();
}
}
/*
// ATTEMPT TWO
#include <FastLED.h>
#define NUM_LEDS 15
#define DATA_PIN 4
#define BUTTON 3
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
pinMode(BUTTON, INPUT_PULLUP);
}
void loop(){
if(digitalRead(BUTTON) == LOW){
unsigned long startTime = millis();
unsigned long currentTime;
int colorIndex = 0;
while((currentTime = millis()) - startTime < 5000){ // Runs for 5 seconds
for(int i = 0; i < NUM_LEDS; i++){
switch (colorIndex){
case 0: leds[i] = CRGB::Red; break;
case 1: leds[i] = CRGB::Green; break;
case 2: leds[i] = CRGB::Blue; break;
case 3: leds[i] = CRGB::Yellow; break;
case 4: leds[i] = CRGB::Cyan; break;
case 5: leds[i] = CRGB::Magenta; break;
case 6: leds[i] = CRGB::Orange; break;
}
}
FastLED.show();
delay(100); // Blink White
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(100);
colorIndex = (colorIndex + 1) % 7;
}
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
FastLED.show();
}
}*/
/*
// ATTEMPT ONE
#include <FastLED.h>
#define NUM_LEDS 15
#define DATA_PIN 4
#define BUTTON 3
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
pinMode(BUTTON, INPUT_PULLUP);
}
void loop() {
if(digitalRead(BUTTON)==LOW){
unsigned long startTime = millis();
while(millis()-startTime < 7000){
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Red;
}
FastLED.show();
delay(1000);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::White;
}
FastLED.show();
delay(45);
for(int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
FastLED.show();
}
}
}
*/