This post is slightly out of sync with my previous ones. I was digging around in my parts box and found my real time clock (RTC) module, a TinyRTC v1. I then realized that I had not posted any of my findings when I used it. Well I had a few minutes today, so I decided to dust off the RTC and see if it was still working.
A real time clock is something many new hobbyist might take for granted. Living in a world of computers with integrated RTCs and internet connections, it's easy to forget just what it takes to keep track of the time. While any Arduino can give you the time since it's last restart (or pretty close to it anyway). To keep track of the time displayed on your cuckoo clock you will need some external hardware and a continuous power supply. Various people have come up with good combinations of said hardware, and all you need to do is buy a RTC module.
The module I will be using is a Tiny RTC v1 module. They are commonly found on Ebay called "Real Time Clock DS1307 I2C AT24C32" or similar. Communication is done over an I2C interface. It has a battery on-board that can supposedly last for several years.
SetRTC sets the RTC with a time you hardcode into the sketch. GetRTC simply displays the time given from the RTC. Both sketches require the Wire library and the I2C address. To find the I2C address, use THIS I2C scanner.
SetRTC to your Arduino. Then hit the reset button at the moment you want to set the clock.
Now we can upload the GetRTC. Open the Serial Monitor and watch the seconds tick by. An interesting note, if you unplug the GND and reattach it, the time gets corrupted, and you will have to reset the time.
Now, while this method works, I would be remiss if did not mention the Time library. It has many other functions that may be useful depending on your situation. I have not explored them, but I assume it works well. To set the time using the library you will need to download Processing. By using a Processing sketch, you can sync the clock's time to that of your computer.
That's all for today. Go forth and make data loggers, binary clocks, and other exciting projects.