Sounds like my clock project (which I have done no work on in several months!)
Here's my code, maybe you could try it. Also you could post your own code?
//Colour Clock
//PaulRB
//Jul 2014
//Hardware: Arduino Micro Pro, DS3231 RTC, 1m 60 x RGB LED WS2812B
#include <Adafruit_NeoPixel.h>
#define LEDStripPin 10
#define RTCSQWPin 7
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, LEDStripPin, NEO_GRB + NEO_KHZ800);
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//RTC Data
#define RTCadrs 0x68
#define RTCrequestTime 0x00
#define RTCrequestTemp 0x11
#define RTCsetControl 0x0E
void setup() {
Wire.begin();
Serial.begin(38400);
//setRTCtime(0x52, 0x21, 0x03, 0x07, 0x14);
setRTCcontrol(B0000000); // enable 1Hz output
strip.begin();
strip.show(); // Initialize all pixels to 'off'
pinMode(RTCSQWPin, INPUT_PULLUP);
//lcd.begin(16,2); // initialize the lcd
}
byte LastRTCSQW, CurrRTCSQW;
byte secHand, minHand, hourHand;
void loop() {
char buff[80];
byte RTCsecs,RTCmins,RTChours,RTCdow,RTCday,RTCmonth,RTCyear;
LastRTCSQW = CurrRTCSQW;
CurrRTCSQW = digitalRead(RTCSQWPin);
if (LastRTCSQW == LOW && CurrRTCSQW == HIGH) {
//get current date & time from RTC
Wire.beginTransmission(RTCadrs);
Wire.write(byte(RTCrequestTime));
Wire.endTransmission();
Wire.requestFrom(RTCadrs, 3);
RTCsecs = Wire.read();
RTCmins = Wire.read();
RTChours = Wire.read();
//RTCdow = Wire.read();
//RTCday = Wire.read();
//RTCmonth = Wire.read();
//RTCyear = Wire.read();
//sprintf (buff, "Date: %02x/%02x/20%02x Time: %02x:%02x:%02xGMT", RTCday, RTCmonth, RTCyear, RTChours, RTCmins, RTCsecs);
//sprintf (buff, "Time: %02x:%02x:%02x", RTChours, RTCmins, RTCsecs);
//lcd.home();
//lcd.print (buff);
byte secHandNew = bcdToDec(RTCsecs);
byte minHandNew = bcdToDec(RTCmins);
byte hourHandNew = (bcdToDec(RTChours) % 12) * 5 + minHandNew / 12;
for (int i=1; i<256; i+=2) {
if (hourHand != hourHandNew) {
strip.setPixelColor(hourHand, strip.Color(255-i, 255-i, 0));
strip.setPixelColor(hourHandNew, strip.Color(i, i, 0));
}
if (minHand != minHandNew) {
strip.setPixelColor(minHand, strip.Color(255-i, 0, 255-i));
strip.setPixelColor(minHandNew, strip.Color(i, 0, i));
}
if (secHand != secHandNew) {
if (secHand == hourHand) {
strip.setPixelColor(hourHand, strip.Color(i, i, 0));
}
else if (secHand == minHand) {
strip.setPixelColor(minHand, strip.Color(i, 0, i));
}
else {
strip.setPixelColor(secHand, strip.Color(0, 255-i, 255-i));
}
if (secHandNew == hourHand) {
strip.setPixelColor(secHandNew, strip.Color(i, i, i));
}
else if (secHandNew == minHand) {
strip.setPixelColor(secHandNew, strip.Color(i, i, i));
}
else {
strip.setPixelColor(secHandNew, strip.Color(0, i, i));
}
}
strip.show();
//delay(1);
}
hourHand = hourHandNew;
minHand = minHandNew;
secHand = secHandNew;
}
LastRTCSQW = digitalRead(RTCSQWPin);
}
void setRTCtime(byte mins, byte hours, byte date, byte month, byte year) {
Wire.beginTransmission(RTCadrs);
Wire.write(byte(RTCrequestTime));
Wire.write(byte(0));
Wire.write(mins);
Wire.write(hours);
Wire.write(byte(0));
Wire.write(date);
Wire.write(month);
Wire.write(year);
Wire.endTransmission();
}
void setRTCcontrol(byte control) {
Wire.beginTransmission(RTCadrs);
Wire.write(byte(RTCsetControl));
Wire.write(control);
Wire.endTransmission();
}
byte bcdToDec(byte bcd) {
return (bcd & 0x0F) + ((bcd & 0xF0) >> 1) + ((bcd & 0xF0) >> 3);
}
Notice I have the square-wave output from the RTC module set to 1Hz and connect it to an input pin. The sketch polls that pin to synchronise with the RTC.
Paul