Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

HORLOGE LCD

By: axel_67 on Jan 16th, 2012  |  syntax: None  |  size: 0.94 KB  |  views: 195  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }