#include <Wire.h>
#include <RTClib.h>
#include <SevSeg.h>
RTC_DS1307 rtc;
SevSeg sevseg;
void setup() {
Wire.begin();
rtc.begin();
// Konfigurasi perangkat keras 7-Segment Display
byte numDigits = 4;
byte digitPins[] = {2, 3, 4, 5};
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
bool resistorsOnSegments = false; // false for common anode display
bool updateWithDelaysIn = true;
byte hardwareConfig = COMMON_ANODE; // common anode
bool leadingZeros = false; // no leading zeros in the display
bool disableDecPoint = false;
sevseg.begin(
hardwareConfig, numDigits, digitPins, segmentPins,
resistorsOnSegments, updateWithDelaysIn, leadingZeros, disableDecPoint);
if (!rtc.isrunning()) {
// Set the time if the RTC is not running
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
int hour = now.hour();
int minute = now.minute();
// Display the time on the 7-Segment Display
int timeToDisplay = (hour * 100) + minute;
sevseg.setNumber(timeToDisplay, 2); // 2 decimal places
sevseg.refreshDisplay();
delay(10); // Update the display every second
}