Thank you Jack and Riva for your answers.
Riva because I am quite new to the Arduino. How can I use your code?
What I am asking is how can I use void adjustClock() function on my program?
My code is a very simple code and i state it below:
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup () {
lcd.begin(16, 2);
lcd.clear();
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
lcd.clear(); // Clear the LCD screen
lcd.print("Time: ");
if (now.hour() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.hour(), DEC); // Output current hour
lcd.print(":");
if (now.minute() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.minute(), DEC); // Output current minute
lcd.print(":");
if (now.second() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.second(), DEC);
lcd.setCursor(0, 1);
lcd.print("Date: ");
if (now.day() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.day(), DEC); // Output current hour
lcd.print(":");
if (now.month() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.month(), DEC); // Output current minute
lcd.print(":");
if (now.year() < 10) lcd.print("0"); // Check if we need to add leading zero
lcd.print(now.year(), DEC);
Serial.println();
delay(1000);
lcd.clear();
}
Thank you!!!