Advertisement
Guest User

Arduino Clock

a guest
Nov 4th, 2017
2,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <DS1302.h>  
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. DS1302 rtc(2, 3, 4);
  6. LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
  7.  
  8. void setup() {
  9.   rtc.halt(false);
  10.   rtc.writeProtect(false);
  11.   Serial.begin(9600);
  12.   lcd.begin(16,2);  
  13. // Modify the below lines just once and upload, then comment or delete them!
  14.   rtc.setDOW(SATURDAY);  // Set the day of the week      
  15.   rtc.setTime(13, 05, 40); // Set the time hh:mm:ss
  16.   rtc.setDate(04, 11, 2017); // Set the date dd:mm:yyyy
  17. }
  18.  
  19. void loop() {
  20.   lcd.setCursor(0, 0);
  21.   lcd.print(rtc.getTimeStr());
  22.   lcd.setCursor(8, 0);
  23.   lcd.print(rtc.getDOWStr(FORMAT_SHORT));
  24.   lcd.setCursor(1,1);
  25.   lcd.print("*");
  26.   lcd.setCursor(3, 1);
  27.   lcd.print(rtc.getDateStr());
  28.   lcd.setCursor(14, 2);
  29.   lcd.print("*");
  30.   delay (1000);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement