#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd (12,11,5,4,3,2);
RTC_DS3231 rtc;
char namaHari [7][12]= {"Ahad", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
void setup()
{
// put your setup code here, to run once:
pinMode(8,OUTPUT );
lcd.begin(20,4);
rtc.begin();
if(rtc.lostPower()) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
lcd.setCursor(5,1); lcd.print( " JAM DIGITAL " );
lcd.setCursor(5,2); lcd.print( " LAB LISTRIK " );
delay(1000);
lcd.clear ();
}
void loop()
{
// put your main code here, to run repeatedly:
DateTime now = rtc.now();
lcd.setCursor (2,0);
lcd.print (namaHari[now.dayOfTheWeek()]);
lcd.print (",");
printAngka(now.day());
lcd.print ("-");
printAngka(now.month());
lcd.print ("-");
printAngka (now.year());
lcd.setCursor(5,1);
printAngka(now.hour());
lcd.print (":");
printAngka(now.minute());
lcd.print(":");
printAngka(now.second()); tone(8,1000,50);
lcd.setCursor(2,3);
lcd.print("SMKN 2 SURAKARTA");
delay(5000);
}
void printAngka (int digits){
if ( digits < 10 ) {
lcd.print('0');
lcd.print(digits);
}
else lcd.print(digits);
}