#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
RTC_DS1307 rtc;
#define LED 2
int jam, menit, detik, hari, tanggal, bulan, tahun;
char temp[33];
char nama_hari[7][7]={"Ahad", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
lcd.backlight();
lcd.init();
lcd.setCursor(0,0); lcd.print("Nama Anda");
lcd.setCursor(0,1); lcd.print("Asal");
rtc.begin();
rtc.adjust(DateTime(2024,5,6,14,55,55));
delay(2000); lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now = rtc.now();
jam = now.hour();
menit= now.minute();
detik = now.second();
tanggal = now.day();
bulan = now.month();
tahun = now.year();
hari = now.dayOfTheWeek();
if(jam==14 && menit==56 && detik==0) digitalWrite(LED, HIGH);
else if(jam== 14 && menit==56 && detik==10 ) digitalWrite(LED, LOW);
sprintf(temp, "JAM %02d:%02d:%02d WIB", jam,menit,detik);
lcd.setCursor(0,0); lcd.print(temp);
sprintf(temp, "%s,%02d-%02d-%0d", nama_hari[hari], tanggal, bulan, tahun);
lcd.setCursor(0,1); lcd.print(temp);
}