I'm not sure if this is the right area for this topic, if not can the mods please move it.
I am using a DS1307 breakout as part of a project where I want to write the time and date to a Nokia 3310 LCD. The LCD works as expected, but if I remove the RTC breakout from the project the (! begin()) method never gets called. Instead it calls the (! isrunning()) method.
Here is the code I am using:
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include "RTClib.h"
#include <Wire.h>
#define BACKLIGHT_PIN 7
RTC_DS1307 rtc;
Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3); //Download the latest Adafruit Library in order to use this constructor
int contrast = 35;
/*************************************************************************/
void setup() {
Serial.begin(115200);
display.begin();
display.clearDisplay();
if (! rtc.begin()) { // Does not detect missing RTC
Serial.println(F("Couldn't find RTC"));
display.clearDisplay();
display.setTextSize(2);
display.setCursor(5, 0);
display.print("RTC");
display.setCursor(5, 25);
display.print("MISSING");
display.display();
while (1);
}
if (! rtc.isrunning()) { // missing RTC is detected here instead!
Serial.println(F("RTC is NOT running!"));
Serial.println(F("Starting RTC now..."));
display.clearDisplay();
display.setTextSize(2);
display.setCursor(5, 0);
display.print("RTC");
display.setCursor(5, 25);
display.print("FAIL");
display.display();
// following line sets the RTC to the date & time this sketch was compiled
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
/*********************************************************************************/
void loop() {
// put your main code here, to run repeatedly:
}
void setContrast() {
display.setContrast(contrast);
display.display();
}