I won 5 Tiny RTC modues in an auction & paid 25p each ! - OK, so they did not come with a battery!
There are lots of libraries on the Net to drive these things, but I wanted to play with I2C & BCD !
The displayTime function & BCD conversion functions were taken from other articles on the net.
The code is very simple. With it, you can set each register individually & display the register data & Time & Date in a readable format.
The Tiny RTC has a programmable SQW output which I have set to 1 Hz (Control Register 7) which is used to trigger an ISR which updates the screen (every second !).
Here is a very useful document - https://www.sparkfun.com/datasheets/Components/DS1...
I2C pins are 4 &5 on Arduino Uno, but different on the Mega, Leonardo etc. See https://www.arduino.cc/en/Reference/Wire
A useful article (for BCD) is http://tronixstuff.com/2010/05/20/getting-started-with-arduino-chapter-seven/
The code is very self explanatory! The I2C address of the RTC is fixed at ADDRESS 0x68.
To modify the registers, un-comment and set the values in the call to set_td()
// set_td(7,10); // set SQW = 1Hz
// set_td(2,21); // set(register,value) eg hours reg==2, set to 9.00pm // set_td(6,17) eg year register == 6, set to 17
This is very basic but I learned a lot just by playing with this device.
Have fun !
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.