#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "RTClib.h"
#include <Servo.h>
Servo myservo;
RTC_DS1307 rtc;
LiquidCrystal_I2C lcd(0x27,16,2);
char daysOfTheWeek[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
void setup() {
// put your setup code here, to run once:
myservo.attach(3);
Serial.begin(9600);
lcd.begin (16,2); // initialize the lcd
lcd.backlight();//To Power ON the back light
if (! rtc.begin())
{
lcd.print("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning())
{
lcd.print("RTC is NOT running!");
}
//rtc.adjust(DateTime (F(_DATE_), F(_TIME_)));//auto update from computer time
rtc.adjust(DateTime (2024, 11, 19, 13, 32, 10));// MENYESUAIKAN TGL & WAKTU SEKARANG
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now = rtc.now();
lcd.setCursor(0, 1);
lcd.print("Waktu :");
lcd.print(" ");
lcd.print(now.hour());
lcd.print(':');
lcd.print(now.minute());
lcd.print(':');
lcd.print(now.second());
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Tanggal :");
lcd.print(" ");
lcd.print(daysOfTheWeek [now.dayOfTheWeek()]);
lcd.print(" ");
lcd.print(now.day());
lcd.print('/');
lcd.print(now.month());
lcd.print('/');
lcd.print(now.year());
lcd.print(" ");
lcd.scrollDisplayLeft();
delay(200);
}