#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.begin(16, 2);
lcd.backlight();
lcd.print("JAM DIGITAL....");
Serial.begin(9600);
if (!rtc.begin()) {
lcd.clear();
lcd.print("Couldn't find RTC");
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
lcd.clear();
lcd.print("RTC lost power");
Serial.println("RTC lost power, let's set the time!");
// Uncomment the following line to set the date and time to the time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// Or set to a specific date & time
// rtc.adjust(DateTime(2024, 5, 16, 12, 0, 0));
}
lcd.clear();
lcd.print("JAM DIGITAL:)");
delay(2000);
lcd.clear();
}
void loop() {
DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print(now.year(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
delay(1000);
}