Arduino or code not working as ordered. Whats going on???

Im trying to program the time and date with an IR remote. The results are no where as expected and processes are skipped. :roll_eyes:
Very strange if you ask me…

Here is my code:

#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
#include <IRremote.h>

int RECV_PIN = 9;

IRrecv irrecv(RECV_PIN);

decode_results results;

const int RELAY_0 = A0;
const int RELAY_1 = A1;
etc...
#define one 0x801
#define two 0x802
etc...

void setup()
{
  pinMode(RELAY_0, OUTPUT);
  pinMode(RELAY_1, OUTPUT);
  etc...
  pinMode(13, OUTPUT);
  irrecv.enableIRIn();  // start the receiver
  Serial.begin(9600);
}
int on = 0;
unsigned long last = millis();
boolean cycle = true;  //auto-cylce mode

void loop() {
  int mn;  //variables to be passed into RTC
  int hr;
  int dow;
  int day;
  int mth;
  int yr;
  int x = 0;
  int y = 0;
  int w = 0;
  
  int buttonValue = digitalRead(RECV_PIN);
   while (irrecv.decode (&results)) {
    while (x == 0){
    RTC.stop();
    RTC.set(DS1307_SEC,30);
          Serial.println(" Time and Date must be programmed first. \n");
      Serial.println(" Set the Minute using the remote \n");
      if (results.value == one){     //if button 1 on irremote is pressed...
        int mn = 1;                //set Minutes to 1
        RTC.set(DS1307_MIN,mn);
        cycle = false;
        x=1;                      //end while, move on to next while
        //gui();
      }
      else if (results.value == two){
        int mn = 2;
        RTC.set(DS1307_MIN,mn);
        cycle = false;
        x=1;
      }else if (results.value == three){
        int mn = 3;
        RTC.set(DS1307_MIN,mn);
        cycle = false;
        x=1;
      }else if (results.value == four){
        int mn = 4;
        RTC.set(DS1307_MIN,mn);
        cycle = false;
        x=1;
      }
      else if (results.value == five){  //Needs to be completed, ignore for now
        Serial.println("5\n");
        cycle = false;
        x=1;
      }else if (results.value == six){
        Serial.write("6\n");
        cycle = false;
        x=1;
      }else if (results.value == seven){
        Serial.write("7\n");
        cycle = false;
        x=1;
      }else if (results.value == eight){
        Serial.write("8\n");
        cycle = false;
        x=1;
      }else if (results.value == nine){
        Serial.write("9\n");
        cycle = false;
        x=1;
      }else if (results.value == zero){
        Serial.write("0\n");
        cycle = false;
        x=1;
      }
      delay(300);
      irrecv.resume();   // receive next value
    }
      while(y == 0){
      Serial.println(" Set the Hour using the remote. \n" );
      Serial.println(" Using a 24 hour clock format, example: 4pm would be 16. \n" );
      if (results.value == one){
        int hr = 1;               //sets 1 to hour
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;                  //if y = 1, move on to the next while
      }else if (results.value == two){
        int hr = 2;
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;
      }else if (results.value == three){
        int hr = 3;
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;
      }else if (results.value == four){
        int hr = 4;
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;
      }else if (results.value == five){
        int hr = 5;
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;
      }
       delay(300);
      irrecv.resume();
      }
      while(w == 0){
      Serial.println(" Set the Day of the Week using the remote, A week begins on a Sunday. \n" );
      if (results.value == one){
        int dow = 1;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == two){
        int dow = 2;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == three){
        int dow = 3;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == four){
        int dow = 4;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == five){
        int dow = 5;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == six){
        int dow = 6;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }else if (results.value == seven){
        int dow = 7;
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }
       delay(300);
      irrecv.resume();
      }

      Serial.println(" Set the Date using the remote. \n");
      if (results.value == 1){
        int day = 1;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }else if (results.value == 2){
        int day = 2;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }else if (results.value == 3){
        int day = 3;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      } else if (results.value == 4){
        int day = 4;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      } else if (results.value == 5){
        int day = 5;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      } else if (results.value == 6){
        int day = 6;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }else if (results.value == 7){
        int day = 7;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      } else if (results.value == 8){
        int day = 8;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      } else if (results.value == 9){
        int day = 9;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }else if (results.value == 1 && 0){
        int day = 10;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }else if (results.value == 1 && 1){
        int day = 11;
        RTC.set(DS1307_MIN,day);
        cycle = false;
      }
       delay(300);
      irrecv.resume();

      Serial.println( "Set the Month. \n");
      if (results.value == 1){
        int mth = 1;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 2){
        int mth = 2;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 3){
        int mth = 3;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 4){
        int mth = 4;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      } else if (results.value == 5){
        int mth = 5;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 6){
        int mth = 6;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      } else if (results.value == 7){
        int mth = 7;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 8){
        int mth = 8;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 9){
        int mth = 9;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 1 && 0){
        int mth = 10;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 1 && 1){
        int mth = 11;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }else if (results.value == 1 && 2){
        int mth = 12;
        RTC.set(DS1307_MIN,mth);
        cycle = false;
      }
       delay(300);
      irrecv.resume();

      Serial.println(" Set the year \n");
      Serial.println(" Enter the last 2 digits of the year, for example: If the year is 2011, enter: 11 \n");
   }

      RTC.set(DS1307_YR,11);   //sets year to 2011
      RTC.start();

           //Display time and date
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print("      ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.print(RTC.get(DS1307_YR,false)); //read year 
  Serial.println();
  delay(1000);
}

And here are the results, If you can see, it skips the if statements and resets the clock but the year is set fine, seconds are not and it does not increment.
I press the number two on my remote and as you will see it is passed into the correct position but what happens next? Look and see.

They will be on the reply right below this post since i have exceeded the maximum characters allowed on this forum.

Here are the Results...

0:0:0      0/0/2011
0:0:0      0/0/2011     [color=red]//As you can see, the If statements are skipped and the clock is reset for some odd reason[/color]
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011    [color=green]// Here is when i pressed #2 on the remote[/color]
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Set the Hour using the remote. 

 Using a 24 hour clock format, example: 4pm would be 16. 

 Set the Day of the Week using the remote, A week begins on a Sunday. 

 Set the Date using the remote. 

Set the Month. 

 Set the year // ignore

 Enter the last 2 digits of the year, for example: If the year is 2011, enter: 11 // ignore

0:2:0      0/0/2011
0:2:0      0/0/2011
0:2:0      0/0/2011
0:2:0      0/0/2011   [color=green]//Here is when i pressed a different # on the remote[/color]
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote

Try moving this section out of void loop and back up before void setup.

The problem might be that these are getting declared as new variables each time loop starts, resetting them to 0. Similar discussion in another topic tonight over global variables (declared prior to setup) and local (declared in a function).

int mn; //variables to be passed into RTC int hr; int dow; int day; int mth; int yr; int x = 0; int y = 0; int w = 0;

Tried that already and just again, ints x,y,w had to be global or inside the loop. It actually works worse that way lol... :roll_eyes:

the results look like: 0:0:0 0/0/2011 0:0:0 0/0/2011 0:0:0 0/0/2011 0:0:0 0/0/2011 0:0:0 0/0/2011 //This is where i pressed a button on the remote Time and Date must be programmed first.

Set the Minute using the remote

Time and Date must be programmed first.

Set the Minute using the remote

Time and Date must be programmed first.

Alright, what about these lines? int on = 0; unsigned long last = millis(); boolean cycle = true; //auto-cylce mode

They are not in setup or void. Are they getting run?

What do you do with int buttonValue = digitalRead(RECV_PIN); buttonValue after you read the pin?

Sorry about dribbling the questions out, my eyes are kinda tired.

I appreciate your help.

To answer your questions: int on = 0; unsigned long last = millis(); where used but i cut the section of the code out that used them since i tried to uprgarde my code, they will be used later.

boolean cycle = true; //auto-cylce mode is being used.

and the: int buttonValue = digitalRead(RECV_PIN); isnt being used at the moment but will be once i take care of this major problem im having.

I dont think it hurts to keep them in there even though they arent in use. I might as well comment them out though.

can you put in some print statements to see what results.value is coming up with for value?

print it after every irrecv.resume(); statement

Will it come back with 2 digits? else if (results.value == 1 && 0) or will this statement just do some funky logical function for you resulting in this perhaps else if (0)

Do you know that the remote is even being read properly? Seems to me that your sketch is overly complicated. There is a pattern between the value returned results.value and the value that you set mn, hr, etc. to, that you are ignoring.

Your code could be considerably shorted if you separated the obtaining a value from using of that value. Create a function that blocks until a number is available, then return that number.

int getDigitFromRemote()
{
   // block until there is a value to return
   return value;
}

Then, you can set the time much easier:

int mn = getDigitFromRemote() * 10 + getDigitFromRemote();
int hr = getDigitFromRemote() * 10 + getDigitFromRemote();
int day = getDigitFromRemote() * 10 + getDigitFromRemote();
int mth = getDigitFromRemote() * 10 + getDigitFromRemote();
// set the time

Not only will your code be much shorter, it will be much easier to understand, and much easier to debug, since you can isolate problems. This approach will also handle setting the time to 12:30 on November 20th, which your current code can't even imagine doing.

True, i was meaning to condense the code to something more readable once it was working properly.

Yes there are correct values coming out of the remote and into the micro controller, i tested this using a different program i had running.

This is the updated code:

void loop() {

int mn = getDigitFromRemote() * 10 + getDigitFromRemote();
int hr = getDigitFromRemote() * 10 + getDigitFromRemote();
int dow = getDigitFromRemote();
int day = getDigitFromRemote() * 10 + getDigitFromRemote();
int mth = getDigitFromRemote() * 10 + getDigitFromRemote();
int yr = getDigitFromRemote() * 10 + getDigitFromRemote();
// set the time
  
  int x = 0;
  int y = 0;
  int w = 0;
  int q = 0;
  int r = 0;
  
  int buttonValue = digitalRead(RECV_PIN);
   while (irrecv.decode (&results)) {
    while (x == 0){
    RTC.stop();
    RTC.set(DS1307_SEC,30);
          Serial.println(" Time and Date must be programmed first. \n");
      Serial.println(" Set the Minute using the remote \n");
      if (x==0){     
      RTC.set(DS1307_MIN,mn);
      cycle = false;
        x=1;                      
        //gui();
      }
      delay(300);
      irrecv.resume();  // receive next value
      Serial.println("Minutes Done.\n");
    }
      while(y == 0){
      Serial.println(" Set the Hour using the remote. \n" );
      Serial.println(" Using a 24 hour clock format, example: 4pm would be 16. \n" );
      if (y==0){
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;                  //if y = 1, move on to the next while
      }
       delay(300);
      irrecv.resume();
      Serial.println("Hours done.\n");
      }
      while(w == 0){
      Serial.println(" Set the Day of the Week using the remote, A week begins on a Sunday. \n" );
      if (w==0){
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }
       delay(300);
      irrecv.resume();
      Serial.println("Day of Week done.\n");
      }
      while(q == 0){
      Serial.println(" Set the Date using the remote. \n");
      if (q==0){
      RTC.set(DS1307_MIN,day);
        cycle = false;
        q=1;
      } 
       delay(300);
      irrecv.resume();
      Serial.println("Day done.\n");
      }
      while(r == 0){
      Serial.println( "Set the Month. \n");
      if (r=0){
        RTC.set(DS1307_MIN,mth);
        cycle = false;
        r=1;
      } 
       delay(300);
      irrecv.resume();
      Serial.println("Month done.\n");
      }

      //Serial.println(" Set the year \n");
      //Serial.println(" Enter the last 2 digits of the year, for example: If the year is 2011, enter: 11 \n");
   }

      RTC.set(DS1307_YR,11);   //sets year to 2011
      RTC.start();


           //Display time and date
    
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print("      ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.print(RTC.get(DS1307_YR,false)); //read year 
  Serial.println();

  delay(1000);

}

int getDigitFromRemote()
{
   return results.value;
}

and the results are:

0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011       //This is where i pressed a button on the remote
 Time and Date must be programmed first. 

 Set the Minute using the remote 

Minutes Done.

 Set the Hour using the remote. 

 Using a 24 hour clock format, example: 4pm would be 16. 

Hours done.

 Set the Day of the Week using the remote, A week begins on a Sunday. 

Day of Week done.

 Set the Date using the remote. 

Day done.                       // I pressed a button again somewhere around here

Set the Month. 

Month done.

Set the Month. 

Month done.

Set the Month. 

Month done.

Set the Month. 

Month done.

The code to actually get a value from the remote goes in the getDigitFromRemote function, in place of the comment. The function needs to block until it has a value to return.

It still doesnt explain why it skips all the while and if statements, resets the clock first and starts displaying that first. Why is this happening?

88: It still doesnt explain why it skips all the while and if statements, resets the clock first and starts displaying that first. Why is this happening?

the result.value is what decodes the raw values into something more readable like a hex value for example, how would i attempt to use this block you are suggesting?

Oops sorry wrong use of qoute...

"The code to actually get a value from the remote goes in the getDigitFromRemote function, in place of the comment. The function needs to block until it has a value to return."

the result.value is what decodes the raw values into something more readable like a hex value for example, The hex value of each button is defined as one, two, three...

How would i attempt to use this block you are suggesting?

How would i attempt to use this block you are suggesting?

This code, from your original post:

   while (irrecv.decode (&results)) {
    while (x == 0){
    RTC.stop();
    RTC.set(DS1307_SEC,30);
          Serial.println(" Time and Date must be programmed first. \n");
      Serial.println(" Set the Minute using the remote \n");
      if (results.value == one){     //if button 1 on irremote is pressed...
        int mn = 1;                //set Minutes to 1

is supposed to get a value from the remote, and convert the value (one, two, three, etc.) to an integer.

Put this code in getNumberFromRemote().

Get rid of the stuff that messes with the clock, and the while x == loop, and return the numeric equivalent (1, 2, 3, etc.).

Did that, still doesnt explain why the first thing that shows up on the serial monitor is the clock reseting... it makes no sense if you ask me.

still doesnt explain why the first thing that shows up on the serial monitor is the clock reseting... it makes no sense if you ask me.

The first thing you were doing in loop is this:

void loop() {
int mn = getDigitFromRemote() * 10 + getDigitFromRemote();
int hr = getDigitFromRemote() * 10 + getDigitFromRemote();
int dow = getDigitFromRemote();
int day = getDigitFromRemote() * 10 + getDigitFromRemote();
int mth = getDigitFromRemote() * 10 + getDigitFromRemote();
int yr = getDigitFromRemote() * 10 + getDigitFromRemote();

Since this function was not blocking, waiting for a remote button press, these values are all set to 0.

Then, you had a bunch of code to read a remote button press that did not block, either. With no remote button press being available to read, the while loop was skipped.

The next code is this:

      RTC.set(DS1307_YR,11);   //sets year to 2011
      RTC.start();

Looks to me like the first thing the loop function actually does is set the clock to all zeros, except the year.

Ahhhh :open_mouth: I understand what you mean now.

I have updated the code but only enhanced button 1 press, the rest will be finished when working. Here is the updated code:

#define one 0x801
#define two 0x802
#define three 0x803
#define four 0x804
#define five 0x805
#define six 0x806
#define seven 0x807
#define eight 0x808
#define nine 0x809
#define zero 0x800
#define power 0x80C
#define enter 0x80A
#define sleep 0x826
#define chanup 0x820
#define chandwn 0x821
#define volup 0x810
#define voldwn 0x811

void setup()
{
  pinMode(RELAY_0, OUTPUT);
  pinMode(RELAY_1, OUTPUT);
  pinMode(RELAY_2, OUTPUT);
  pinMode(RELAY_3, OUTPUT);
  pinMode(RELAY_4, OUTPUT);
  pinMode(RELAY_5, OUTPUT);
  pinMode(13, OUTPUT);
  irrecv.enableIRIn();  // start the receiver
  Serial.begin(9600);
}
int x = 0;
int y = 0;
int w = 0;
int q = 0;
int r = 0;
int on = 0;
unsigned long last = millis();
boolean cycle = true;  //auto-cylce mode

void loop() {

int mn = getDigitFromRemote() * 10 + getDigitFromRemote();
int hr = getDigitFromRemote() * 10 + getDigitFromRemote();
int dow = getDigitFromRemote();
int day = getDigitFromRemote() * 10 + getDigitFromRemote();
int mth = getDigitFromRemote() * 10 + getDigitFromRemote();
int yr = getDigitFromRemote() * 10 + getDigitFromRemote();
// set the time
  
  int buttonValue = digitalRead(RECV_PIN);
   while (irrecv.decode (&results)) {
    RTC.stop();
    RTC.set(DS1307_SEC,30);
      Serial.println(" CHECK ERROR 1 ");
      if (x==0){     
      RTC.set(DS1307_MIN,mn);
      cycle = false;
        x=1;                      
        //gui();
      }
      delay(300);
      irrecv.resume();  // receive next value
      Serial.println("Minutes Done.\n");
      if (y==0){
        RTC.set(DS1307_MIN,hr);
        cycle = false;
        y = 1;                  //if y = 1, move on to the next while
      }
       delay(300);
      irrecv.resume();
      Serial.println("Hours done.\n");
      if (w==0){
        RTC.set(DS1307_MIN,dow);
        cycle = false;
        w = 1;
      }
       delay(300);
      irrecv.resume();
      Serial.println("Day of Week done.\n");
      if (q==0){
      RTC.set(DS1307_MIN,day);
        cycle = false;
        q=1;
      } 
       delay(300);
      irrecv.resume();
      Serial.println("Day done.\n");
      if (r=0){
        RTC.set(DS1307_MIN,mth);
        cycle = false;
        r=1;
      } 
       delay(300);
      irrecv.resume();
      Serial.println("Month done.\n");
  }

      RTC.set(DS1307_YR,11);   //sets year to 2011
      RTC.start();


           //Display time and date
    
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print("      ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.print(RTC.get(DS1307_YR,false)); //read year 
  Serial.println();

  delay(1000);

}

int getDigitFromRemote()
{
   while (irrecv.decode (&results)) {
      Serial.println(" Time and Date must be programmed first. \n");
      Serial.println(" Set the Minute using the remote \n");
      if (results.value == one){     //if button 1 on irremote is pressed...
        int mn = 1;                //set Minutes to 1
        cycle = false;
        return mn;    
        //gui();
      }
      delay(300);
      irrecv.resume();   // receive next value
      Serial.println(" Set the Hour. \n" );
      Serial.println(" Using a 24 hour clock format, example: 4pm would be 16. \n" );
      if (results.value == one){
        int hr = 1;               //sets 1 to hour
        cycle = false;
        return hr;
      }
       delay(300);
      irrecv.resume();
      Serial.println(" Set the Day of the Week. \n A week begins on a Sunday. \n" );
      if (results.value == one){
        int dow = 1;
        cycle = false;
        return dow;
      }
       delay(300);
      irrecv.resume();
      Serial.println(" Set the Date. \n");
      if (results.value == 1){
        int day = 1;
        cycle = false;
        return day;
      } 
       delay(300);
      irrecv.resume();
      Serial.println( "Set the Month. \n");
      if (results.value == 1){
        int mth = 1;
        cycle = false;
        return mth;
      } 
      }
       delay(300);
      irrecv.resume();

      Serial.println(" Set the year. \n");
      Serial.println(" Enter the last 2 digits of the year, for example: If the year is 2011, enter: 11 \n");
   }

}

The results will be on the reply right below this due to the issue with exceeding 9500 characters on this forum.

I really appreciate the help and suggestions :)

But the results arent looking much better:

0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011    // Here is where i pressed button 1
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Set the Hour. 

 Using a 24 hour clock format, example: 4pm would be 16. 

 Set the Day of the Week. 
 A week begins on a Sunday. 

 Set the Date. 

0:0:0      0/0/2011
0:0:0      0/0/2011
0:0:0      0/0/2011   // I press button 1 again here
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 CHECK ERROR 1 
Minutes Done.

Hours done.

Day of Week done.

Day done.

Month done.

0:11:0      0/0/2011
0:11:0      0/0/2011
0:11:0      0/0/2011  //And this is where I continue to press 1
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Set the Hour. 

 Using a 24 hour clock format, example: 4pm would be 16. 

 Set the Day of the Week. 
 A week begins on a Sunday. 

 Set the Date. 

0:11:0      0/0/2011
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Set the Hour. 

 Using a 24 hour clock format, example: 4pm would be 16. 

 Set the Day of the Week. 
 A week begins on a Sunday. 

 Set the Date. 

0:11:0      0/0/2011
 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote 

 Time and Date must be programmed first. 

 Set the Minute using the remote