I'm using an ATMEGA 328 board. Pin 5 of DS1307 is connected to A4 and Pin 6 is connected to A5.
The problem is that I get an lcd output display of 165:165:165
#include <LiquidCrystal.h>
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 RTC;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int motor=2;
int backlight = 7;
void setup() {
Serial.begin(57600);
Wire.begin();
RTC.begin();
lcd.begin(20, 4);
pinMode(backlight, OUTPUT);
pinMode(motor, OUTPUT);
}
void loop() {
digitalWrite(backlight, HIGH);
DateTime now = RTC.now();
int hour = now.hour();
int minute = now.minute();
int second = now.second();
int hourFeed1 = 7;
int minuteFeed = 16;
int hourFeed2 = 17;
lcd.setCursor(0,0);
if ((hour == hourFeed1 && minute == minuteFeed) || (hour == hourFeed2 && minute == minuteFeed))
{
lcd.print("Dispense Feeds");
digitalWrite(motor, HIGH);
delay(1000);
digitalWrite(motor, LOW);
delay(1000);
lcd.clear();
}
else {
lcd.setCursor(0,0);
lcd.print(" Time:");
lcd.setCursor(-0,2);
lcd.print(" ");
lcd.print(hour);
lcd.print(':');
lcd.print(minute);
lcd.print(':');
lcd.print(second);
}
}
If you've never set the time on the RTC, the output you get is likely to be the time in Shanghai.
If I recall it correctly, the output you are seeing is due to inadequate power. If you are using the USB cable to power your gear, this is very likely to be the case and it is time to get a 9v wall wart.
If you are using the popular cheapo DS1307 module, it seems that, if you are suffering from a shortage of power, the first signal comes from the clock. This sounds unreasonable, but it might have something to do with the battery charging.
Are you using a standalone chip that you've wired yourself, or a breakout board like those found at sparkfun and adafruit? (SparkFun Real Time Clock Module - BOB-12708 - SparkFun Electronics) Double check all your connections; I recently spent a week trouble shooting a DS1307 that was behaving very strangely. Turns out it was from a open ground connection.
I know it has been a while, but maybe people are helped with it:
I had a selfbuilt RTC with DS1307: worked. Then I soldered something on it and got the 165 output. tried a lot of things... no effect.
Popped in a new chip and voila, worked.
So I guess the 165/165 output is the DS1307's way of saying... "I am dead"
I found the DS1307 to be very fragile: that was teh 2nd one that gave up