////////////////////////////lcd clock using arduino and ds1307/////////////////////////
///////////////////////////senthamizhanjackie@gmail.com//////////////////////
////////////////////////////////created on 20/12/18//////////////////////////////////
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.print(" lcd clock ");
lcd.setCursor(0,1);
lcd.print(" code dt 181220 ");
delay(2000);
lcd.clear();
}
void loop()
{
tmElements_t tm;
if (RTC.read(tm))
{
lcd.setCursor(0,0);
lcd.print("Time ");
print2digits(tm.Hour);
lcd.print(':');
print2digits(tm.Minute);
lcd.print(':');
print2digits(tm.Second);
lcd.setCursor(0,1);
lcd.print("Date ");
lcd.print(tm.Day);
lcd.print('/');
lcd.print(tm.Month);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));
}
delay(1000);
}
void print2digits(int number)
{
if (number >= 0 && number < 10)
{
lcd.print('0');
}
lcd.print(number);
}
///////////////////////////senthamizhanjackie@gmail.com//////////////////////
////////////////////////////////created on 20/12/18//////////////////////////////////
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.print(" lcd clock ");
lcd.setCursor(0,1);
lcd.print(" code dt 181220 ");
delay(2000);
lcd.clear();
}
void loop()
{
tmElements_t tm;
if (RTC.read(tm))
{
lcd.setCursor(0,0);
lcd.print("Time ");
print2digits(tm.Hour);
lcd.print(':');
print2digits(tm.Minute);
lcd.print(':');
print2digits(tm.Second);
lcd.setCursor(0,1);
lcd.print("Date ");
lcd.print(tm.Day);
lcd.print('/');
lcd.print(tm.Month);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));
}
delay(1000);
}
void print2digits(int number)
{
if (number >= 0 && number < 10)
{
lcd.print('0');
}
lcd.print(number);
}