#include <FastLED.h>
#define DATA_PIN 4
// #define NUM_LEDS 16
// #define NUM_LEDS 30
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
CRGB leds_backup[NUM_LEDS];
void setup() {
// Start Serial port
Serial.begin(115200);
pinMode(18, INPUT_PULLUP);
//FASTLED leds obj
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS); //FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
Serial.println(FastLED.getBrightness());
// FastLED.setBrightness(FastLED.getBrightness()+50);
FastLED.setBrightness(200);
Serial.println(FastLED.getBrightness());
/**/
leds[0] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[15] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[30] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[45] = CRGB(0, 0, 250); FastLED.show(); delay(200);
/**/
/*
leds[0] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[7] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[15] = CRGB(0, 0, 250); FastLED.show(); delay(200);
leds[23] = CRGB(0, 0, 250); FastLED.show(); delay(200);
*/
/*
leds[0] = CRGB(0, 0, 250); FastLED.show(); delay(100);
leds[4] = CRGB(0, 0, 250); FastLED.show(); delay(100);
leds[8] = CRGB(0, 0, 250); FastLED.show(); delay(100);
leds[12] = CRGB(0, 0, 250); FastLED.show(); delay(100);
*/
// SetTime(3,45,0);
SetTime(12,10,0);
}
void loop() {
// leds[t] = CRGB(rood, groen, blauw);
/*
leds[0] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[1] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[2] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[3] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[4] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[5] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[6] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
leds[7] = CRGB(50, 0, 0); FastLED.show(); delay(1000);
*/
delay(5000);
for ( int t=1 ; t < 20+1 ; t++ ){
SetDimMode();
leds_backup[t] = leds[t];
if (leds[t] == CRGB(0, 0, 0))
{
leds[t] = CRGB(0, 200, 0);
FastLED.show();
Serial.print("Led ");
Serial.print(t);
Serial.println(" green");
delay(500);
}else{
leds[t] = CRGB(0, 200, 0);
FastLED.show();
delay(250);
leds[t] = leds_backup[t];
FastLED.show();
delay(250);
}
}
delay(2000);
for ( int t=1 ; t < 20+1 ; t++ ){
SetDimMode();
leds[t] = CRGB(0, 0, 0);
leds[t] = leds_backup[t];
FastLED.show();
Serial.print("Led ");
Serial.print(t);
Serial.println(" black");
delay(500);
}
/**/
FastLED.show();
}
void SetTime(int nHour, int nMinute, int nSecond){
if (60/12*nHour != 60){
leds[60/12*nHour] = CRGB(200, 0, 0); FastLED.show(); delay(200);
}else{
leds[0] = CRGB(200, 0, 0); FastLED.show(); delay(200);
}
if (60/60*nMinute != 60){
leds[60/60*nMinute] = CRGB(255, 106, 0); FastLED.show(); delay(200);
}else{
leds[0] = CRGB(255, 106, 0); FastLED.show(); delay(200);
}
}
void SetDimMode(){
if (digitalRead(18) == HIGH){
FastLED.setBrightness(200);
}else{
FastLED.setBrightness(100);
}
}