#include <ESP32Servo.h>
#include "RTClib.h"
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
Servo myservo;
int jam = 18;int menit = 32 || int jam = 18; int menit= 35;
int status = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(200);
Serial.println("DS1307RTC Read Test");
Serial.println("-------------------");
myservo.attach(15);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
}
void loop() {
waktuRTC(now);
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
// myservo.write(180);
DateTime now = rtc.now();
Serial.print("Current time: ");
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
if(now.hour()==jam && now.minute()==menit && status==1){
myservo.write(180);
delay(1000);
myservo.write(0);
delay(1000);
}
myservo.write(0);
status = 1;
}