#include <Wire.h>
#include "LiquidCrystal_I2C.h"
#include <RTClib.h>
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu"};
LiquidCrystal_I2C lcd(0x27, 16, 2);
int perintah;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
Wire.begin();
if (! rtc.begin())
{
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
lcd.init();
lcd.backlight();
lcd.print("yes");
}
void loop() {
DateTime now = rtc.now();
lcd.setCursor( 0,0);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(",");
lcd.print(now.day());
lcd.print("-");
lcd.print(now.month());
lcd.print("-");
lcd.print(now.year());
lcd.setCursor(4,1);
lcd.print(now.hour());
lcd.print(":");
lcd.print(now.minute());
lcd.print(":");
lcd.print(now.second());
if ((now.hour() == 7 and now.minute() == 0 and now.second() == 0)) {
// myStepper.step(1000);
}
delay(1000);
//perintah untuk mengatur waktu alarm
if (now.minute() == 42) {
tone(2, HIGH);
}
perintah = Serial.parseInt();
if (perintah == 2){
tone(2, LOW);
Serial.println("Alarm mati");
}
}