//includes the RTC library
#include "RTClib.h"
RTC_DS1307 rtc;
//includes the SevSeg library
#include "SevSeg.h"
SevSeg sevseg;
//colon pin
const int Colon = 13;
String cum = "";
String minute = "";
void setup() {
byte numDigits = 4;
byte digitPins[] = {2, 3, 4, 5};
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12};
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options
bool updateWithDelays = false; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = true; // Use 'true' if your decimal point doesn't exist or isn't connected
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
updateWithDelays, leadingZeros, disableDecPoint);
sevseg.setBrightness(90);
//starts serial
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
}
void loop() {
//Defines now
DateTime now = rtc.now();
//Prints the time via serial
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.println();
if (now.minute() <= 9){
minute = "0" + String(now.minute());
cum = String(now.hour()) + String(minute);
sevseg.setNumber(cum.toInt());
}
else{
cum = String(now.hour()) + String(now.minute());
sevseg.setNumber(cum.toInt());
}
sevseg.refreshDisplay();
}
/*
.----------------.
| .--------------. |
| | A | |
| | | |
| | | |
| |F B| |
| | | |
| | | |
| | G | |
| '--------------' |
| .--------------. |
| | G | |
| | | |
| | | |
| |E C| |
| | | |
| | | |
| | D | |
| '--------------' |
'----------------'
*/