Devices & Components
Arduino Uno Rev3
Breadboard (generic)
10kOhm Resistor
PCF8563
jumpers
100nF Capacitor
Crystal 32kHz
Project description
Code
Code snippet #1
arduino
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 23 24//init the real time clock 25Rtc_Pcf8563 rtc; 26 27void setup() 28{ 29 //clear out the registers 30 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, sec 35 rtc.setTime(1, 15, 0); 36 Serial.begin(9600); 37} 38 39void loop() 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"); 49 delay(1000); 50} 51 52 53 54
Comments
Only logged in users can leave comments