Lots of projects require a battery backed time and date display or stamp. In this project we took a SainSmart DS1307 RTC Module and connected it to a SainSmart UNO & LCD Shield. We are displaying the date and time on the lcd display.
Normally, on a lcd, if you print 35, then 7, you’ll get 75, as the 7 slides to the left, and leaves the old digit. I’m using a if statement to detect if a number is less than 10, then inserting a 0 first. This maintains the placement. You can insert a space if you prefer.
We used a Real Time Clock library from Adafruit as the base project, and made our modifications to that.
To set the time, pull the battery from the unpowered clock module, reinsert it, and upload the sketch to the Arduino. The clock module will be set to your computers date and time at the time the sketch was compiled / uploaded.
The 4 connections necessary are:
+5vdc to RTC VCC
Gnd to RTC Gnd
SDA to SDA (A4)
SCL to SCL (A5)
You can add a relay, buzzer and alarm code to turn things on and off or notify you.