Perhaps I'm asking too many questions all at once.
This is the function I call resetTime():
void resetTime(){
//global variables: year, month, date, hour, minute, wait, edit, YesPin, NoPin.
byte rst; //variable of 'for' loop
//1=year. 2=month, 3=date, 4=hour, 5=minute.
for (rst = 0; rst <=5; rst++) {
switch (rst) {
case 0:
lcd.clear();
break;
case 1: // year
while (edit == 1) {
lcd.print("The year is 20");
lcd.print(year);
lcd.setCursor(6, 2);
lcd.print("Correct?");
lcd.setCursor(0, 3);
lcd.print("No Yes");
if (digitalRead(NoPin) == 1) {
year = year + 1;
if (year > 21)year = 16;
delay(250);
lcd.clear();
}
if (digitalRead(YesPin) == 1) {
lcd.clear();
edit = 0;
}
} // End year loop
break;
case 2:
edit = 1;
lcd.clear();
while (edit == 1) {
lcd.print("The month is ");
if (month < 10)lcd.print(" ");
lcd.print(month);
lcd.setCursor(6, 2);
lcd.print("Correct?");
lcd.setCursor(0, 3);
lcd.print("No Yes");
if (digitalRead(NoPin) == 1) {
month = month + 1;
if (month > 12)month = 1;
delay(500);
lcd.clear();
}
if (digitalRead(YesPin) == 1) {
lcd.clear();
edit = 0;
}
} // End month loop
break;
case 3:
edit = 1;
lcd.clear();
while (edit == 1) {
lcd.print("The date is ");
if (date < 10)lcd.print(" ");
lcd.print(date);
lcd.setCursor(6, 2);
lcd.print("Correct?");
lcd.setCursor(0, 3);
lcd.print("No Yes");
if (digitalRead(NoPin) == 1) {
date = date + 1;
if (date > 31)date = 1;
delay(500);
lcd.clear();
}
if (digitalRead(YesPin) == 1) {
lcd.clear();
edit = 0;
}
} // End date loop
break;
case 4:
edit = 1;
lcd.clear();
while (edit == 1) {
lcd.print("The hour is ");
if (hour < 10)lcd.print(" ");
lcd.print(hour);
lcd.setCursor(6, 2);
lcd.print("Correct?");
lcd.setCursor(0, 3);
lcd.print("No Yes");
if (digitalRead(NoPin) == 1) {
hour = hour + 1;
if (hour > 23)month = 0;
delay(500);
lcd.clear();
}
if (digitalRead(YesPin) == 1) {
lcd.clear();
edit = 0;
}
} // End hour loop
break;
case 5:
edit = 1;
lcd.clear();
while (edit == 1) {
lcd.print("The minute is ");
if (minute < 10)lcd.print(" ");
lcd.print(month);
lcd.setCursor(6, 2);
lcd.print("Correct?");
lcd.setCursor(0, 3);
lcd.print("No Yes");
if (digitalRead(NoPin) == 1) {
minute = minute + 1;
if (minute > 59)minute = 0;
delay(500);
lcd.clear();
}
if (digitalRead(YesPin) == 1) {
lcd.clear();
edit = 0;
}
} // End minute loop
break;
}
}
}
What I am imagining is that the first time through the for loop, the display is cleared (switch case 0).
'break' then closes switch case and so we return to the 'for' loop which increments rst to 1.
Switch case is re-entered at case 2 and the global year variable is edited. Then break takes us out and back to 'for' which increments rst to 2.
Case 2 edits the month variable. and so on until rst is 5 when minute is edited, then the function closes.
The trouble is that it doesn't work like that so there's something I'm missing. Sometimes case 1 is presented, sometimes it goes straight to case 5 but never to the other cases.