/*
PROGRAM MENYALAKAN LED DENGAN JEDA WAKTU/RELAY
SILAHKAN DIGUNAKAN DAN DIBAGIKAN
SEMOGA BERMANFAAT
[email protected]
29-09-2023 06:58
*/
#include "RTClib.h"
//#include "Clock.h"
RTC_DS1307 rtc;
char namaHari[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27, 16,2);
void setup() {
// put your setup code here, to run once:
lcd.begin();
pinMode(2, OUTPUT); // relay jenis LOW
//rtc.adjust(DateTime(2023, 9, 29, 17, 59, 45));
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print(namaHari[now.dayOfTheWeek()]);
lcd.print(',');
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.println();
if (now.hour()==6 && now.minute()<1) {
//delay(3000);
//untuk LED
digitalWrite(2, HIGH); //menyalakan selama delay
delay(2000); // 15 menit
digitalWrite(2, LOW); //mematikan selama delay
delay(1000); // 45 menit
} else digitalWrite(2, LOW);
}