#include <RTClib.h>
RTC_DS1307 rtc;
#include <Adafruit_NeoPixel.h>
#define STARTPIXEL 0 // 0 = 12 o'clock is at the top
#define NUMPIXELS 60 //
#define PIXELPIN 8 // arduino PWM pin
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIXELPIN, NEO_GRB + NEO_KHZ800);
byte pixelColorRed, pixelColorGreen, pixelColorBlue; // color values
#define DAYTIME 255
#define NIGHTTIME 127
int flag = 1;
void setup() {
rtc.begin();
// rtc.adjust(DateTime(__DATE__, __TIME__)); // RUN ONCE to set RTC to date/time sketch was compiled
pinMode(PIXELPIN, OUTPUT);
strip.begin();
strip.clear(); // clear any set pixels
strip.show(); // turn all pixels off
}
void loop() {
DateTime now = rtc.now(); // get current dtg
for (int i = 0; i < strip.numPixels(); i++) {
if (i == now.second())
pixelColorBlue = 255;
else
pixelColorBlue = 0;
if (i == now.minute())
pixelColorGreen = 255;
else
pixelColorGreen = 0;
if (i == now.hour())
pixelColorRed = 255;
else
pixelColorRed = 0;
// place the pixel along the clock/strip and color it
strip.setPixelColor((i + STARTPIXEL) % 60, strip.Color(pixelColorRed, pixelColorGreen, pixelColorBlue));
}
strip.show();
}