#include <LiquidCrystal.h>
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#include "RTClib.h"
RTC_DS1307 rtc;
int jam,menit,detik;
void setup () {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Test RTC");
Serial.begin(57600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
void loop() {
DateTime time = rtc.now();
jam = time.hour();
menit = time.minute();
detik = time.second();
lcd.setCursor(0, 1);
lcd.print(jam);
lcd.print(':');
lcd.print(menit);
lcd.print(':');
lcd.print(detik);
//Delay 5s
delay(500);
}