Problem changing date on LCD with DS1307 RTC

So, I've been banging my head against the wall for the past couple days on this. I can get everything to work (mega2560 R3, 16x02 LCD, DS1307 rtc) and the first time I uploaded the henning karlson sketch, it worked perfectly. So, happy I managed to get something accomplished, I unplugged the arduino and set it aside for a day. Came back 2 days later, and the date was 3 months ahead. No clue how that happened. So, figuring some of my jumpers got knocked loose, or something silly, I rewired the whole setup on my breadboard. Now for the life of me I cannot get the day to display correctly on the LCD. I can change the time, month, and year no problem, but heck if the day will change. Which I find extremely odd. Especially considering all I changed within the sketch were the pins used, and the date/time. :frowning:

Am I missing something stupidly simple? Or could this be due to a hardware issue? Any help will be appreciated.

Here's the sketch I have so far:

// DS1307_LCD (C)2010 Henning Karlsen
// web: Electronics - Henning Karlsen
//
// A quick demo of how to use my DS1307-library to make a quick
// clock using a DS1307 and a 16x2 LCD.
//
// I assume you know how to connect the DS1307 and LCD.
// DS1307: SDA pin -> SDA 20
// SCL pin -> SCL 21
// LCD: DB7 -> Arduino Digital 50
// DB6 -> Arduino Digital 48
// DB5 -> Arduino Digital 46
// DB4 -> Arduino Digital 44
// E -> Arduino Digital 42
// RS -> Arduino Digital 40

#include <LiquidCrystal.h>
#include <DS1307.h>

// Init the DS1307
DS1307 rtc(20, 21);

// Init the LCD
LiquidCrystal lcd(40, 42, 44, 46, 48, 50);

void setup()
{
// Set the clock to run-mode
rtc.halt(false);

// Setup LCD to 16x2 characters
lcd.begin(16, 2);

// The following lines can be commented out to use the values already stored in the DS1307
rtc.setDOW(THURSDAY); // Set Day-of-Week
rtc.setTime(1, 50, 30); // Set the time
rtc.setDate(04, 18, 2013); // Set the date

// Set SQW/Out rate to 1Hz, and enable SQW
rtc.setSQWRate(SQW_RATE_1);
rtc.enableSQW(true);
}

void loop()
{
// Display time centered on the upper line
lcd.setCursor(4, 0);
lcd.print(rtc.getTimeStr());

// Display abbreviated Day-of-Week in the lower left corner
lcd.setCursor(0, 1);
lcd.print(rtc.getDOWStr(FORMAT_SHORT));

// Display date in the lower right corner
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());

// Wait one second before repeating :slight_smile:
delay (1000);
}

Found this on the playground for setDate:
void setDate(byte day, byte weekday, byte month, byte century, byte year)

This is in the example program:

rtc.setDate(14, 6, 3, 1, 10);

Maybe your argument format?

I'll be honest I'm just starting out and dabbling. I'm not even sure how to use the code you posted. Also noticed that when i plugged the arduino in today, it kept the time properly, but it's a month ahead. XD I'm thinking I'll just figure something else out instead of using the HK sketch.

So, now I really feel like an idiot. I misread how the date format was set in the sketch. :fearful: The date format was not the MM:DD:YYYY I'm used to, it is DD::MM::YYYY. So when I was trying to change the date to April 16, 2013, I put in 4/16/2013. When in actuality, I needed to input the date as 16/4/2013. I knew it had to be something really simple that was messing me up.

On the other hand, I do feel good about figuring out the problem finally.