#include<Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
Wire.begin();
pinMode(2, OUTPUT );
lcd.init();
lcd.backlight();
if (!rtc.begin()){
Serial.println("RTC Tidak Terhubung ");
while(1);
}
}
void loop() {
DateTime now = rtc.now();
int tahun = now.year();
int bulan = now.month();
int tanggal = now.day();
int jam = now.hour();
int menit = now.minute();
int detik = now. second ();
lcd.setCursor(0,0);
lcd.println(String() + "tanggal:" + tanggal + "-" + bulan + "-" + tahun );
lcd.setCursor(0,1);
lcd.println(String() + "Waktu :" + jam + ":" + menit + ":" + detik );
Serial.println(String() + "tanggal:" + tanggal + "-" + bulan + "-" + tahun );
Serial.println(String() + "Waktu :" + jam + ":" + menit + ":" + detik );
Serial.println();
// put your main code here, to run repeatedly:
delay(1000); // this speeds up the simulation
if((jam== 9) && ( menit == 33 ) && (detik == 10) ){
digitalWrite(2, HIGH);
delay (5000);
digitalWrite(2, LOW);
}
}