I took the battery out of the RTC and now every time I deploy a program it shows the time and date as:
00:00:01
01/01/2000
Can someone please help me?
Here is a program that was working fine and now is not since the battery incident:
#include <LiquidCrystal.h>
#include <Time.h>
#include <TimeLib.h>
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
RTC_DS1307 RTC;
void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
lcd.begin(16, 2);
if (! RTC.isrunning()) {
lcd.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
//RTC.adjust(DateTime(DATE, TIME));
}
}
void loop () {
DateTime now = RTC.now();
lcd.setCursor(0,0);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
lcd.print(now.hour(), DEC);
lcd.print(':');
byte minute = now.minute();
if (minute < 10)
{
lcd.print("0");
}
lcd.print(now.minute(), DEC);
lcd.print(':');
byte second = now.second();
if (second < 10)
{
lcd.print("0");
}
lcd.print(now.second(), DEC);
}