#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#include "RTClib.h"
RTC_DS1307 rtc;

char nama2hari[7][12] = {"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"};
void setup () 
{
  Serial.begin(9600);
  lcd.begin (20,4);  // Set lcd 
  lcd.backlight();
  if (! rtc.begin()) 
  {
    lcd.print("RTC tidak tersedia");
    while (1);
  }
if (! rtc.isrunning()) 
  {
    lcd.print("RTC tidak berfungsi");
  }
    //rtc.adjust(DateTime(2023, 11, 4, 15, 21, 0));//Update otomatis dari jam komputer
    //rtc.adjust(DateTime(2021, 11, 25, 17, 30, 0));// Atur waktu manual 
}
void loop () 
{
    DateTime now = rtc.now();
    lcd.setCursor(0, 1);
    lcd.print("JAM:");
    lcd.print(" ");
    lcd.print(now.hour());
    lcd.print(':');
    lcd.print(now.minute());
    lcd.print(':');
    lcd.print(now.second());
lcd.print("  ");

    lcd.setCursor(0, 0);
    lcd.print("TGL:");
    lcd.print(" ");
    //lcd.print(nama2hari[now.namahari()]);
    lcd.print(" ");
    lcd.print(now.day());
    lcd.print('/');
    lcd.print(now.month());
    lcd.print('/');
    lcd.print(now.year());
    lcd.print("  ");   
}
GND5VSDASCLSQWRTCDS1307+