Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
1,147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <MyRealTimeClock.h>
  2.  
  3. MyRealTimeClock myRTC(5,4,0); // Assign Digital Pins
  4.  
  5. void setup() {
  6. Serial.begin(9600);
  7.  
  8.  
  9. /* To set the current time and date in specific format
  10. | Second 00 | Minute 11 | Hour 21 | Week Day 06 | Day 17 |  Month 8 | Year 2019 |
  11. */
  12.  
  13. myRTC.setDS1302Time(00, 11, 21, 06, 17, 8, 2019);
  14. }
  15.  
  16. void loop() {
  17.  
  18. // Allow the update of variables for time / accessing the individual element.
  19. myRTC.updateTime();
  20.  
  21. Serial.print("Current Date / Time: ");
  22. Serial.print(myRTC.dayofmonth); // Element 1
  23. Serial.print("/");
  24. Serial.print(myRTC.month); // Element 2
  25. Serial.print("/");
  26. Serial.print(myRTC.year); // Element 3
  27. Serial.print(" ");
  28. Serial.print(myRTC.hours); // Element 4
  29. Serial.print(":");
  30. Serial.print(myRTC.minutes); // Element 5
  31. Serial.print(":");
  32. Serial.println(myRTC.seconds); // Element 6
  33. delay( 5000);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement