Components and supplies
Resistor 220 ohm
Breadboard 830 points with Wire Kit
Crystal 32kHz
10k 1/4w resistor
LCD 16x2
PCF8563
Arduino UNO
10K potentiometers
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 <Wire.h> 22#include <Rtc_Pcf8563.h> 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} 37 38void loop() 39{ 40 //both format functions call the internal getTime() so that the 41 //formatted strings are at the current time/date. 42 Serial.print(rtc.formatTime()); 43 Serial.print("\ \ 44"); 45 Serial.print(rtc.formatDate()); 46 Serial.print("\ \ 47"); 48 delay(1000); 49} 50 51 52 53
Code snippet #2
arduino
1#include <Wire.h> 2#include <Rtc_Pcf8563.h> 3// include the RTC library 4#include <LiquidCrystal.h> 5 6 7//init the real time clock 8Rtc_Pcf8563 rtc; 9 10 11 12// initialize the library with the numbers of the interface pins 13LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 14 15void setup() { 16 // set up the LCD's number of columns and rows: 17 lcd.begin(16, 2); 18 lcd.print(" Arduino Clock!"); 19 while(1500 - millis() > 0); 20 pinMode(13, OUTPUT); 21} 22 23void loop() { 24 lcd.setCursor(0, 0); 25 lcd.print("Date: "); 26 lcd.print(rtc.formatDate()); 27 28 lcd.setCursor(0, 1); 29 lcd.print("Time: "); 30 lcd.print(rtc.formatTime()); 31} 32 33
Code snippet #1
arduino
1/* Demonstration of Rtc_Pcf8563 Set Time. 2 * Set the clock to a time 3 then loop over reading time and 4 * output the time and date to the serial console. 5 6 * 7 * I used a RBBB with Arduino IDE, the pins are mapped a 8 * bit differently. 9 Change for your hw 10 * SCK - A5, SDA - A4, INT - D3/INT1 11 * 12 * After loading 13 and starting the sketch, use the serial monitor 14 * to see the clock output. 15 16 * 17 * setup: see Pcf8563 data sheet. 18 * 1x 10Kohm pullup on Pin3 19 INT 20 * No pullups on Pin5 or Pin6 (I2C internals used) 21 * 1x 22 0.1pf on power 23 * 1x 32khz chrystal 24 * 25 * Joe Robertson, jmr 26 27 * orbitalair@bellsouth.net 28 */ 29#include <Wire.h> 30#include <Rtc_Pcf8563.h> 31 32//init 33 the real time clock 34Rtc_Pcf8563 rtc; 35 36void setup() 37{ 38 //clear out 39 the registers 40 rtc.initClock(); 41 //set a time to start with. 42 //day, 43 weekday, month, century(1=1900, 0=2000), year(0-99) 44 rtc.setDate(14, 6, 3, 1, 45 10); 46 //hr, min, sec 47 rtc.setTime(1, 15, 0); 48} 49 50void loop() 51{ 52 53 //both format functions call the internal getTime() so that the 54 //formatted 55 strings are at the current time/date. 56 Serial.print(rtc.formatTime()); 57 Serial.print("\ \ 58"); 59 60 Serial.print(rtc.formatDate()); 61 Serial.print("\ \ 62"); 63 delay(1000); 64} 65 66 67 68
Code snippet #2
arduino
1#include <Wire.h> 2#include <Rtc_Pcf8563.h> 3// include the RTC library 4 5#include <LiquidCrystal.h> 6 7 8//init the real time clock 9Rtc_Pcf8563 10 rtc; 11 12 13 14// initialize the library with the numbers of the interface 15 pins 16LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 17 18void setup() { 19 // set 20 up the LCD's number of columns and rows: 21 lcd.begin(16, 2); 22 lcd.print(" 23 Arduino Clock!"); 24 while(1500 - millis() > 0); 25 pinMode(13, OUTPUT); 26} 27 28void 29 loop() { 30 lcd.setCursor(0, 0); 31 lcd.print("Date: "); 32 lcd.print(rtc.formatDate()); 33 34 35 lcd.setCursor(0, 1); 36 lcd.print("Time: "); 37 lcd.print(rtc.formatTime()); 38} 39 40
Downloadable files
Schematics
Schematics
Comments
Only logged in users can leave comments
Arduino_Scuola
7 Followers
•58 Projects
8
0