Created
February 11, 2016 22:18
-
-
Save kachurovskiy/e2b507559bdd6893833a to your computer and use it in GitHub Desktop.
Arduino program showing data from DS1302 clock on 4-digit display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <virtuabotixRTC.h> | |
#include <SevSeg.h> | |
SevSeg sevseg; | |
// Clock DS1302 on analog pins 0 to 2 | |
virtuabotixRTC myRTC(14, 15, 16); | |
void setup() { | |
byte numDigits = 4; | |
// 4-digit display HS420561K-32 on digital pins 2 to 13 | |
byte digitPins[] = {2, 3, 4, 5}; | |
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; | |
sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins); | |
sevseg.setBrightness(90); | |
// Comment out on second run if clock has 3V battery. | |
myRTC.setDS1302Time(40, 13, 23, 3, 11, 2, 2016); | |
} | |
void loop() { | |
myRTC.updateTime(); | |
sevseg.setNumber(myRTC.hours * 100 + myRTC.minutes, 2); | |
sevseg.refreshDisplay(); | |
delay(10); // Optional, to save power. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See comment on line 18. You might want to comment out line 19.