limpingricky

DS3231 + TM1637 + arduino clock

Oct 30th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <Sodaq_DS3231.h>
  3. #include <TM1637Display.h>
  4. #include <Arduino.h>
  5.  
  6. #define CLK 3
  7. #define DIO 2
  8.  
  9. TM1637Display display(CLK, DIO);
  10. //            yyyy, mm, dd, hh, mm, ss, dd
  11. //DateTime dt(2017, 10, 30, 17, 20, 30, 0);
  12. DateTime now;
  13.  
  14.  
  15. const uint8_t SEG_8421[] = {
  16.   SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F | SEG_G, // 8
  17.   SEG_F | SEG_G | SEG_B | SEG_C, // 4
  18.   SEG_A | SEG_B | SEG_G | SEG_E | SEG_D, // 2
  19.   SEG_B | SEG_C // 1
  20. };
  21.  
  22. void setup() {
  23.   Wire.begin();
  24.   rtc.begin();
  25. //  rtc.setDateTime(dt);
  26.  
  27.   display.setBrightness(0x09);
  28.   display.setSegments(SEG_8421);
  29.   delay(1000);
  30. }
  31.  
  32. uint32_t old_TimeStamp;
  33.  
  34. void loop() {
  35.   DateTime now = rtc.now();
  36.   for(int i = 0; i < 14; i++){
  37.     display.showNumberDec(now.hour() * 100 + now.minute(), true, 4, 0);
  38.     delay(500);
  39.   }
  40.   for(int j = 0; j < 2; j++){
  41.     display.showNumberDec(now.second(), false, 4, 0);
  42.     delay(500);
  43.   }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment