#include <RTClib.h>
#include <Servo.h>
Servo motor;
RTC_DS1307 wakturtc;
void setup() {
Serial.begin(9600);
motor.attach(6);
pinMode(7, OUTPUT);
if (!wakturtc.begin()) {
Serial.println("RTC mati/tidak aktif");
while(1);
}
}
void loop() {
DateTime now = wakturtc.now();
int jam = now.hour();
int menit = now.minute();
int detik = now.second();
int tanggal = now.day();
int bulan = now.month();
int tahun = now.year();
Serial.println(String() + "Jam sekarang " + jam + ":" + menit + ":" + detik);
delay(1000);
Serial.println(String() + "Tanggal sekarang " + tanggal + "/" + bulan + "/" + tahun);
delay(1000);
if (detik == 10) {
motor.write(90);
digitalWrite(7, HIGH);
delay(1500);
}
motor.write(0);
digitalWrite(7, LOW);
}