Advertisement
axel_67

HORLOGE LCD

Jan 16th, 2012
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1.  
  2. #include <PCD8544.h>
  3. #include <DS1302.h>
  4.  
  5. // Init the DS1302
  6. DS1302 rtc(2, 3, 4);
  7.  
  8. // Init the LCD
  9. static PCD8544 lcd;
  10.  
  11. void setup()
  12. {
  13. // Set the clock to run-mode, and disable the write protection
  14. rtc.halt(false);
  15. rtc.writeProtect(true);
  16.  
  17. // Setup LCD characters
  18. lcd.begin(84, 48);
  19.  
  20. // // The following lines can be commented out to use the values already stored in the DS1302
  21. // rtc.setDOW(FRIDAY); // Set Day-of-Week
  22. // rtc.setTime(20,45, 0); // Set the time (24hr format)
  23. // rtc.setDate(13, 1, 2012); // Set the date
  24. }
  25.  
  26. void loop()
  27. {
  28. // Display time on the upper line
  29. lcd.setCursor(7, 0);
  30. lcd.print(rtc.getTimeStr());
  31.  
  32. // Display Day-of-Week in the next line
  33. lcd.setCursor(15, 8);
  34. lcd.print(rtc.getDOWStr(FORMAT_LONG));
  35.  
  36. // Display date in the last line
  37. lcd.setCursor(23, 16);
  38. lcd.print(rtc.getDateStr());
  39.  
  40. // Wait one second before repeating :)
  41. delay (1000);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement