Advertisement
phuongpupil2

clock rtclib ds1307

Nov 5th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include "SevSeg.h"
  2. #include <Wire.h>
  3. #include "RTClib.h"
  4. SevSeg Display;
  5. RTC_DS1307 rtc;
  6. unsigned int aa;
  7. unsigned int Time;
  8. //char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  9. void setup()
  10. {
  11. // Wire.begin();
  12. rtc.begin();
  13. byte numDigits = 4;
  14. byte digitPins[] = {10, 11, 12, 13};
  15. byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
  16. bool resistorsOnSegments = true;
  17. bool updateWithDelaysIn = true;
  18. byte hardwareConfig = COMMON_ANODE;
  19. Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  20. Display.setBrightness(100);
  21. Serial.begin(57600);
  22. // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  23. }
  24. void loop()
  25. {
  26. DateTime now = rtc.now;
  27. Serial.println(now.hour(), DEC);
  28. // Time = now.hour() *100 + now.minute();
  29. // Display.setNumber(Time);
  30. // Display.setChars(Time);
  31. // Serial.println(Time);
  32. Serial.println();
  33. delay(3000);
  34. Display.refreshDisplay();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement