Advertisement
RuiViana

Untitled

Jun 8th, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. #include <Wire.h>
  3. #include "RTClib.h"
  4.  
  5. RTC_DS1307 rtc;
  6. //--------------------------------------------------
  7. void setup () {
  8. Serial.begin(57600);
  9. Wire.begin();
  10. rtc.begin();
  11. if (! rtc.isrunning())
  12. {
  13. Serial.println("RTC is NOT running!");
  14. rtc.adjust(DateTime(2015,6,8,19,11,55));
  15. }
  16. }
  17. //--------------------------------------------------
  18. void loop ()
  19. {
  20. DateTime now = rtc.now();
  21.  
  22. Serial.print(now.year(), DEC);
  23. Serial.print('/');
  24. Serial.print(now.month(), DEC);
  25. Serial.print('/');
  26. Serial.print(now.day(), DEC);
  27. Serial.print(' ');
  28. Serial.print(now.hour(), DEC);
  29. Serial.print(':');
  30. Serial.print(now.minute(), DEC);
  31. Serial.print(':');
  32. Serial.print(now.second(), DEC);
  33. Serial.println();
  34.  
  35. Serial.print(" since midnight 1/1/1970 = ");
  36. Serial.print(now.unixtime());
  37. Serial.print("s = ");
  38. Serial.print(now.unixtime() / 86400L);
  39. Serial.println("d");
  40. delay(3000);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement