#include <FastLED.h>
#include <Wire.h>
#include "RTClib.h"
#define LED_PIN 2
#define NUM_LEDS 24
CRGB leds[NUM_LEDS];
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Serial.begin(57600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
void loop() {
// put your main code here, to run repeatedly:
DateTime time = rtc.now();
Serial.print(time.year(), DEC);
Serial.print('/');
Serial.print(time.month(), DEC);
Serial.print('/');
Serial.print(time.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[time.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(time.hour(), DEC);
Serial.print(':');
Serial.print(time.minute(), DEC);
Serial.print(':');
Serial.print(time.second(), DEC);
Serial.println();
if (time.second() % 2 == 0) {
leds[0] = CRGB(255, 0, 0);
FastLED.show();
} else {
leds[0] = CRGB(0, 0, 0);
FastLED.show();
}
int hval = time.hour() / 5;
int mval = time.minute() / 5;
int lmval = 0;
int lhval = 0;
switch(hval) {
case 0:
leds[1] = CRGB(0, 0, 0);
FastLED.show();
leds[2] = CRGB(0, 0, 0);
FastLED.show();
leds[3] = CRGB(0, 0, 0);
FastLED.show();
leds[4] = CRGB(0, 0, 0);
FastLED.show();
lhval = time.hour();
break;
case 1:
leds[1] = CRGB(255, 0, 0);
FastLED.show();
leds[2] = CRGB(0, 0, 0);
FastLED.show();
leds[3] = CRGB(0, 0, 0);
FastLED.show();
leds[4] = CRGB(0, 0, 0);
FastLED.show();
lhval = time.hour() - 5;
break;
case 2:
leds[1] = CRGB(255, 0, 0);
FastLED.show();
leds[2] = CRGB(255, 0, 0);
FastLED.show();
leds[3] = CRGB(0, 0, 0);
FastLED.show();
leds[4] = CRGB(0, 0, 0);
FastLED.show();
lhval = time.hour() - 10;
break;
case 3:
leds[1] = CRGB(255, 0, 0);
FastLED.show();
leds[2] = CRGB(255, 0, 0);
FastLED.show();
leds[3] = CRGB(255, 0, 0);
FastLED.show();
leds[4] = CRGB(0, 0, 0);
lhval = time.hour() - 15;
FastLED.show();
break;
case 4:
leds[1] = CRGB(255, 0, 0);
FastLED.show();
leds[2] = CRGB(255, 0, 0);
FastLED.show();
leds[3] = CRGB(255, 0, 0);
FastLED.show();
leds[4] = CRGB(255, 0, 0);
lhval = time.hour() - 20;
FastLED.show();
break;
}
switch(lhval) {
case 0:
leds[5] = CRGB(0, 0, 0);
FastLED.show();
leds[6] = CRGB(0, 0, 0);
FastLED.show();
leds[7] = CRGB(0, 0, 0);
FastLED.show();
leds[8] = CRGB(0, 0, 0);
FastLED.show();
break;
case 1:
leds[5] = CRGB(255, 0, 0);
FastLED.show();
leds[6] = CRGB(0, 0, 0);
FastLED.show();
leds[7] = CRGB(0, 0, 0);
FastLED.show();
leds[8] = CRGB(0, 0, 0);
FastLED.show();
break;
case 2:
leds[5] = CRGB(255, 0, 0);
FastLED.show();
leds[6] = CRGB(255, 0, 0);
FastLED.show();
leds[7] = CRGB(0, 0, 0);
FastLED.show();
leds[8] = CRGB(0, 0, 0);
FastLED.show();
break;
case 3:
leds[5] = CRGB(255, 0, 0);
FastLED.show();
leds[6] = CRGB(255, 0, 0);
FastLED.show();
leds[7] = CRGB(255, 0, 0);
FastLED.show();
leds[8] = CRGB(0, 0, 0);
FastLED.show();
break;
case 4:
leds[5] = CRGB(255, 0, 0);
FastLED.show();
leds[6] = CRGB(255, 0, 0);
FastLED.show();
leds[7] = CRGB(255, 0, 0);
FastLED.show();
leds[8] = CRGB(255, 0, 0);
FastLED.show();
break;
}
switch(mval) {
case 0:
leds[9] = CRGB(0, 0, 0);
FastLED.show();
leds[10] = CRGB(0, 0, 0);
FastLED.show();
leds[11] = CRGB(0, 0, 0);
FastLED.show();
leds[12] = CRGB(0, 0, 0);
FastLED.show();
leds[13] = CRGB(0, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute();
break;
case 1:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(0, 0, 0);
FastLED.show();
leds[11] = CRGB(0, 0, 0);
FastLED.show();
leds[12] = CRGB(0, 0, 0);
FastLED.show();
leds[13] = CRGB(0, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-5;
break;
case 2:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(0, 0, 0);
FastLED.show();
leds[12] = CRGB(0, 0, 0);
FastLED.show();
leds[13] = CRGB(0, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-10;
break;
case 3:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(0, 0, 0);
FastLED.show();
leds[13] = CRGB(0, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-15;
break;
case 4:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(0, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-20;
break;
case 5:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(0, 0, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-25;
break;
case 6:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(0, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-30;
break;
case 7:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(255, 0, 0);
FastLED.show();
leds[16] = CRGB(0, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-35;
break;
case 8:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(255, 0, 0);
FastLED.show();
leds[16] = CRGB(255, 0, 0);
FastLED.show();
leds[17] = CRGB(0, 0, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-40;
break;
case 9:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(255, 0, 0);
FastLED.show();
leds[16] = CRGB(255, 0, 0);
FastLED.show();
leds[17] = CRGB(255, 255, 0);
FastLED.show();
leds[18] = CRGB(0, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-45;
break;
case 10:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(255, 0, 0);
FastLED.show();
leds[16] = CRGB(255, 0, 0);
FastLED.show();
leds[17] = CRGB(255, 255, 0);
FastLED.show();
leds[18] = CRGB(255, 0, 0);
FastLED.show();
leds[19] = CRGB(0, 0, 0);
FastLED.show();
lmval = time.minute()-50;
break;
case 11:
leds[9] = CRGB(255, 0, 0);
FastLED.show();
leds[10] = CRGB(255, 0, 0);
FastLED.show();
leds[11] = CRGB(255, 255, 0);
FastLED.show();
leds[12] = CRGB(255, 0, 0);
FastLED.show();
leds[13] = CRGB(255, 0, 0);
FastLED.show();
leds[14] = CRGB(255, 255, 0);
FastLED.show();
leds[15] = CRGB(255, 0, 0);
FastLED.show();
leds[16] = CRGB(255, 0, 0);
FastLED.show();
leds[17] = CRGB(255, 255, 0);
FastLED.show();
leds[18] = CRGB(255, 0, 0);
FastLED.show();
leds[19] = CRGB(255, 0, 0);
FastLED.show();
lmval = time.minute()-55;
break;
}
switch(lmval) {
case 0:
leds[20] = CRGB(0, 0, 0);
FastLED.show();
leds[21] = CRGB(0, 0, 0);
FastLED.show();
leds[22] = CRGB(0, 0, 0);
FastLED.show();
leds[23] = CRGB(0, 0, 0);
FastLED.show();
break;
case 1:
leds[20] = CRGB(255, 0, 0);
FastLED.show();
leds[21] = CRGB(0, 0, 0);
FastLED.show();
leds[22] = CRGB(0, 0, 0);
FastLED.show();
leds[23] = CRGB(0, 0, 0);
FastLED.show();
break;
case 2:
leds[20] = CRGB(255, 0, 0);
FastLED.show();
leds[21] = CRGB(255, 0, 0);
FastLED.show();
leds[22] = CRGB(0, 0, 0);
FastLED.show();
leds[23] = CRGB(0, 0, 0);
FastLED.show();
break;
case 3:
leds[20] = CRGB(255, 0, 0);
FastLED.show();
leds[21] = CRGB(255, 0, 0);
FastLED.show();
leds[22] = CRGB(255, 0, 0);
FastLED.show();
leds[23] = CRGB(0, 0, 0);
FastLED.show();
break;
case 4:
leds[20] = CRGB(255, 0, 0);
FastLED.show();
leds[21] = CRGB(255, 0, 0);
FastLED.show();
leds[22] = CRGB(255, 0, 0);
FastLED.show();
leds[23] = CRGB(255, 0, 0);
FastLED.show();
break;
}
// delay(500);
// leds[5] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[6] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[7] = CRGB(0, 0, 255);
// FastLED.show();
// delay(500);
// leds[8] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[9] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[10] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[11] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[12] = CRGB(0, 0, 255);
// FastLED.show();
// delay(500);
// leds[13] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[14] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[15] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[16] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[17] = CRGB(0, 0, 255);
// FastLED.show();
// delay(500);
// leds[18] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[19] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[20] = CRGB(255, 0, 0);
// FastLED.show();
// delay(500);
// leds[21] = CRGB(0, 255, 0);
// FastLED.show();
// delay(500);
// leds[22] = CRGB(0, 0, 255);
// FastLED.show();
// delay(500);
// leds[23] = CRGB(255, 0, 0);
// FastLED.show();
delay(500);
}