Word Clock Code - time is off?

Hello Everyone,

This is my first post so I am going to try and follow all of the rules, but I apologize if I forget something.

Anyways, I have never used an Arduino before, but I saw a 'Word Clock' online, and thought it would be a great project for me to try out!

I quickly realized I was a little over my head, as the programming associated with it is much more detailed than I thought. I have done some basica C++ coding for college , but never created my own program from scratch.

I found some good tutorials online, and have been trying to follow them as closely as possible, but the program I have been referencing doesn't seem to be working correctly.

In the attached program, the time (hour, min, sec) are input manually via the below bit of code:

int  hour=5, minute=07, second=00;

static unsigned long msTick =0;  // the number of Millisecond Ticks since we last 

                                 // incremented the second counter

The creator of this code added a debug feature, to see what time was being input. It should update every minute, and change the statement every 5 minutes (IE: It is Five minutes past five, It is ten minutes past five, etc.)

void incrementtime(void){

  // increment the time counters keeping care to rollover as required

  second=0;

  if (++minute >= 60) {

    minute=0;

    if (++hour == 13) {

      hour=1;  

    }

  }  

  // debug outputs

  Serial.println();

  Serial.print(hour);

  Serial.print(",");

  Serial.print(minute);

  Serial.print(",");

  Serial.println(second);

}

When I run the code, and then view it on the serial monitor, the first line is input correctly (it is five minutes past five), but the subsequent lines are all incorrect. It jumps ahead an hour, then another hour, then 5 minutes for a few iterations, etc.

This code has been used by quite a few people over the years, but it does not appear to be working for me...am I doing something wrong?

Am I missing something obvious? I have copied and pasted it from one of the tutorials exactly (except for updating the initial Hours and Minutes declarations). I am just trying to understand the logic behind this program, so I can apply it to my own version, but I cant figure out why the time is jumping around in this manner.

Word_Clock.ino (11.7 KB)