#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);




}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
rgb1:VDD
rgb1:DOUT
rg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