// Wokwi Library List -> libraries.txt
// TM1637
#include <TM1637.h>
#include "RTClib.h"
// Module connection pins (Digital Pins)
#define CLK 19
#define DIO 21
TM1637 Display1(CLK, DIO);
#define CHAR_BLANK 127
//-----------
// Init the DS1302
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup() {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
Display1.init();
Display1.set(BRIGHT_DARKEST); // กำหนดความสว่าง 0-7 หรือกำหนดผ่านค่าคง
} // BRIGHT_TYPICAL = 2 , BRIGHT_DARKEST = 0 , BRIGHTEST = 7
void loop() {
DateTime now = rtc.now();
Serial.print("Current time: ");
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Display1.display(0, now.day()); // แสดงเลข 1 ที่หลัก 0
Display1.display(2, now.month());
delay(1000);
}