Advertisement
safwan092

Untitled

May 18th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <Wire.h>
  2. #include "RTClib.h"
  3.  
  4. RTC_DS3231 rtc;
  5.  
  6. void setup() {
  7. Serial.begin(9600);
  8. rtc.begin();
  9. if (rtc.lostPower()) {
  10. rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  11. }
  12. }
  13.  
  14. void loop() {
  15. DateTime now = rtc.now();
  16. Serial.print(now.year(), DEC);
  17. Serial.print('/');
  18. Serial.print(now.month(), DEC);
  19. Serial.print('/');
  20. Serial.print(now.day(), DEC);
  21. Serial.print(" ");
  22. Serial.print(now.hour(), DEC);
  23. Serial.print(':');
  24. Serial.print(now.minute(), DEC);
  25. Serial.println();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement