#include <LiquidCrystal_I2C.h>
#include <RTClib.h>

LiquidCrystal_I2C lcd(0x27,16,2);
RTC_DS1307 RTC;

const int buzzer=11;

void setup() {
  lcd.init();
  lcd.backlight();
  RTC.begin();
  pinMode(buzzer,OUTPUT);
  lcd.setCursor(4,0);
  lcd.print("Project");
  lcd.setCursor(2,1);
  lcd.print("Jam Digital");
  delay(3000);
  lcd.clear();
}

void loop() {
  //tone(buzzer,500);
  //digitalWrite(buzzer,HIGH);
  DateTime baca_rtc = RTC.now();
  tampilan_utama();

  int alarm_jam=10;
  int alarm_menit=57;

  if (baca_rtc.hour() == alarm_jam && baca_rtc.minute() == alarm_menit)
  {
    tone(buzzer,500);
    delay(3000);
    while (baca_rtc.hour() == alarm_jam && baca_rtc.minute() == alarm_menit)
    {
      tampilan_utama();
      noTone(buzzer);
    }
  }
  else 
  {
    noTone(buzzer);
  }
}

void tampilan_utama()
{
  DateTime baca_rtc = RTC.now();
  lcd.setCursor(0,0);
  lcd.print("DATE: ");
  lcd.print(baca_rtc.year());
  lcd.print("/");
  lcd.print(baca_rtc.month());
  lcd.print("/");
  lcd.print(baca_rtc.day());
  lcd.setCursor(0,1);
  lcd.print("TIME: ");
  lcd.print(baca_rtc.hour());
  lcd.print("/");
  lcd.print(baca_rtc.minute());
  lcd.print("/");
  lcd.print(baca_rtc.second());
  lcd.print("  ");
}
GND5VSDASCLSQWRTCDS1307+