So I tried to make an Arduino LCD Real Time Clock using the DS1302 RTC.
It works and reads the time stored in the RTC properly, yet every other second, displays empty sets of data
Here's a snapshot of the serial monitor and the sketch
I can't seem to find a problem.
It could be from the library itself but I got it from a video which seemed to work fine in the video.
I'm new in this environment so any type of help is much appreciated. Here's my sketch.
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
DS1302 rtc(2, 3, 4);
void setup()
{
rtc.halt(false);
rtc.writeProtect(false);
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
lcd.setCursor(4, 0);
lcd.print(rtc.getTimeStr());
Serial.print(rtc.getTimeStr());
lcd.setCursor(0, 1);
lcd.print(rtc.getDOWStr(FORMAT_SHORT));
Serial.print(rtc.getDOWStr(FORMAT_SHORT));
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());
Serial.println(rtc.getDateStr());
delay (1000);
}
I gave up and just decided to use a different library instead. It seems like the problem lies with the library itself.
I tried removing anything related to the LCD
, it didn't work. I tried removing anything related to Serial
and still didn't work.
I used a different library and now it works for me!