1/* Demonstration of Rtc_Pcf8563 Set Time.
2 * Set the clock to a time then loop over reading time and
3 * output the time and date to the serial console.
4 *
5 * I used a RBBB with Arduino IDE, the pins are mapped a
6 * bit differently. Change for your hw
7 * SCK - A5, SDA - A4, INT - D3/INT1
8 *
9 * After loading and starting the sketch, use the serial monitor
10 * to see the clock output.
11 *
12 * setup: see Pcf8563 data sheet.
13 * 1x 10Kohm pullup on Pin3 INT
14 * No pullups on Pin5 or Pin6 (I2C internals used)
15 * 1x 0.1pf on power
16 * 1x 32khz chrystal
17 *
18 * Joe Robertson, jmr
19 * orbitalair@bellsouth.net
20 */21#include
22#include
2324//init the real time clock25Rtc_Pcf8563 rtc;2627voidsetup()28{29//clear out the registers30 rtc.initClock();31//set a time to start with.32//day, weekday, month, century(1=1900, 0=2000), year(0-99)33 rtc.setDate(14,6,3,1,10);34//hr, min, sec35 rtc.setTime(1,15,0);36 Serial.begin(9600);37}3839voidloop()40{41//both format functions call the internal getTime() so that the 42//formatted strings are at the current time/date.43 Serial.print(rtc.formatTime());44 Serial.print("\
\
45");46 Serial.print(rtc.formatDate());47 Serial.print("\
\
48");49delay(1000);50}51525354