Program Will Not Re-Start at the Very Beginning

I would like to know what I did wrong. I have a program that runs on an Arduino Mega 2560 that operates a 2 axis robot. It runs well in automatic mode but I added a manual mode component that works but not quite as I expected.

At the very beginning of the auto program, I looked for a 4 by 4 key pad ‘#’ key press and if so the program moves to several options to run in manual mode. If not, it will time out and continue into automatic mode.

The problem is that if I let it time out and continue, when the auto program runs its course, it should start over at the beginning but it re-starts right after the look for key press. By the same token, if I do enter manual mode and go back to auto, the same thing happens. It runs through the auto program but does not look for any key press at the beginning like I would expect.
Why not and how can I fix it? My void loop is posted below.

For general information:
This is what the program does but is probably not important for this discussion. reply #13 I was asking for some guidance that was more general there. reply #28 has the layout and the code for my manual input program that I incorporated into my auto program. It has had a few features add since this so it is a little out of date. Again, I thing that what I am doing wrong is probably pretty straight forward and a common mistake.

void loop()
  lcd.print("Press # to enter");
  lcd.println(" Manual   Mode  ");         
  Serial.println(String("BEGIN keyTime is ") + int(keyTime) + String(" before key 'for' loop"));  

while(keyTime <= 3000)
  //Serial.println(String("Read ") + int(keyTime) + String(" inside key 'for' loop"));  
  //Serial.println("returned from keyPadF");
  keyTime = keyTime + 1;
  Serial.println("Left 'for' to keyPadF");

  digitalWrite(optOutPin1,HIGH);                   // Turn on pin for Home senser
  digitalWrite(optInPin1,HIGH);                    // Turn on pullup resistors
  digitalWrite(optOutPin2,HIGH);                   // Turn on pin for All Stop Sensor
  digitalWrite(optInPin2,HIGH);                    // Turn on pullup resistors
  digitalWrite(optOutPin3,HIGH);                   // Turn on pin for Boom Up senser
  digitalWrite(optInPin3,HIGH);                    // Turn on pullup resistors 

//opticalSensor1 = digitalRead(optOutPin1);

  Serial.println("Pre-Start UP");
onStartUp();   //<<************************  // Re-set the system when it starts or re-starts

  lcd.print("                ");
  lcd.print("                ");
     int stationReadOut;                           // Added so that stationNumber will read correctly
      for (int stationNumber = 0; stationNumber < stationCount; stationNumber++)
             stationReadOut = stationNumber + 1;

             const int stepsToNextStation = distance[stationNumber];
             const int timeForFoodPumping = fTime[stationNumber]; 
             const int timeForWaterPumping = wTime[stationNumber];

             lcd.setCursor(0,0);                   // Upper row (0), character 1 (0)

             moveToNextStation(stepsToNextStation, DIR);

             lcd.setCursor(9, 1);


You never reset Keytime, so on the second iteration around loop, the while loop is ignored.

Think you. How do I do that.

keyTime = 0;?

Wow I'm sorry that I missed that! You have no idea how much grief I have encountered over this point. This applies to several of my issues. Thanks!!!!!!!