Introduction: From Counter to Clock With RTC DS-1302
This time I would like to modify from our previous counter to become a simple clock by using DS-1302 RTC chip.
DS-1302 uses 2 wire interface used by Atmel which is old version of I2C.
Since more space on the left side of the board is needed, we reassembly the component from the counter to the right. And for clarity, the 0.56" 7 segment will be used.
Step 1: Additional Component
- All component in counter
- Crystal 32 KHZ
- RTC DS1302 IC
- Resistors (3 X 10K for pull ups)
- 3V watch battery or 100uF capacitor with 1K pull ups
Or if you prefer you can use separate DS1302 module with battery and connect to to your breadboard.
Step 2: Place DS-1302 Chip
Since we used up all of our digital pins, and we still need 3 more pins for communicate with RTC. So we will use analog pins as GPIO. That way we can connect DS-1302 chip without extra hardware.
In image above we can also use 1 resistor from pin 4 to ground instead of pull ups. Also capacitor as substitute of watch battery (just for sake of prototyping, not to be used as production).
Step 3: Upload the Code
Before upload the code, please change the set time to your current.
// Make a new time object to set the date and time.
// Sunday, September 22, 2013 at 01:38:50.
Time t(2013, 9, 22, 1, 38, 50, Time::kSunday);
// Set the time and date on the chip.
After all finish then, upload program. to test.
If all ok, you can comment the "rtc.time(t)" so that it won't reset to particular time upon boot up.
Now you can show of the clock in your living room or put it in transparent box.