#include <FastLED.h>
const unsigned long eventInterval = 1000;
unsigned long previousTime = 0;
unsigned long currentTime = 0;
unsigned long previousTime2 = 0;
unsigned long currentTime2 = 0;
#define NUM_LEDS 15 /*the number of leds that will light. If */
#define DATA_PINC 6
#define BUTTON_PIN 4
int LED1_state=0;
CRGB ledsC[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, DATA_PINC, GRB>(ledsC, NUM_LEDS);
//FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500);
FastLED.setBrightness(50);
FastLED.clear();
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
currentTime = millis();
FastLED.show();
if((digitalRead(BUTTON_PIN)) == 0){
for(int i = NUM_LEDS - 1; i >= 0; i--){
if(currentTime - previousTime >= eventInterval){
ledsC[i-2] = CRGB::Red;
ledsC[i-1] = CRGB::Red;
ledsC[i] = CRGB::Red;
FastLED.show();
previousTime = currentTime;
}
if(currentTime2 - previousTime2 >= eventInterval){
ledsC[i] = CRGB::Black;
}
Serial.println("Test1");
//delay(100);
}
}
}
// #include <Adafruit_NeoPixel.h>
// #ifdef __AVR__
// #include <avr/power.h>
// #endif
// unsigned long currentTime = millis();
//
// for(int j = NUM_LEDS - 1; i > 0; i--){
// ledsC[j] = CRGB::Black;
// }
// Serial.println("Ice Ice Baby");
// previousTime = currentTime;
// }
// void loop(){
// if((digitalRead(BUTTON_PIN)) == 0){
// shootingStarAnimation(255, 255, 255, 15, 5, 2000);
// Serial.println("Hoiga");
// }
// }
// int a = 14;
// int b = 14;
//DoBlackAnimation();
//while(a < 15){
// Serial.println(previousTime);
//
// }
// for(int i = 0; i <= 15; i++){
// if(currentTime - previousTime >= eventInterval){
// previousTime = currentTime;
// ledsC[i] = CRGB::Red;
// //delay(100);
// Serial.println(i);
// }
//DoAnimation(2);
// ledsC[i] = CRGB::Black;
// FastLED.show();
//ledsC[0] = CRGB::Black;
//}
//}
//}
// void DoAnimation(int j){
// //
//}
// void DoBlackAnimation(){
// for(int i = NUM_LEDS - 1; i >= 0; i--){
// delay(100);
// ledsC[i] = CRGB::Black;
// FastLED.show();
// }
// }