#include <RTClib.h>
#include <Servo.h>
Servo Motor;
RTC_DS1307 rtctime;
void setup() {
Serial.begin(115200);
pinMode(7, OUTPUT);
Motor.attach(6);
rtctime.begin();
}
void RTC() {
DateTime now = rtctime.now();
//Format Jam
int jam = now.hour();
int menit = now.minute();
int detik = now.second();
//Format Tanggal
int tanggal = now.day();
int bulan = now.month();
int tahun = now.year();
//Print
Serial.println(String()+"Jam sekarang : "+jam+":"+menit+":"+menit);
Serial.println(String()+"Tanggal sekarang : "+tanggal+"/"+bulan+"/"+tahun);
delay(1000);
}
void Servo() {
//Lampu Hidup
if(digitalRead(7)==HIGH) {
Motor.write(0);
delay(100);
digitalWrite(7, LOW);
}
//Lampu Mati
else {
Motor.write(90);
delay(100);
digitalWrite(7, HIGH);
}
}
void loop() {
RTC();
Servo();
}