#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
RTC_DS1307 rtc;
int jam, menit, detik;
char temp[33];
void setup() {
lcd.backlight(); lcd.init();
lcd.setCursor(0,0); lcd.print(" Semarang ");
if(rtc.begin()){
lcd.setCursor(0,1); lcd.print(" RTC berhasil ");
} else {
lcd.setCursor(0,1); lcd.print(" RTC gagal ");
}
}
void loop() {
DateTime now = rtc.now();
jam = now.hour();
menit = now.minute();
detik = now.second();
sprintf(temp, "JAM %02d:%02d:%02d WIB", jam, menit, detik);
lcd.setCursor(0,1); lcd.print(temp);
}