Multiple pages one display, auto advance, and have manual advance

I have a display with 4 pages;

  1. = start-up page
  2. = data display page 1
  3. = data display page 2
  4. = data display page 3

So far I have it working by it's self by using a variable ans a switch to check what page to display, once the page is displayed the variable is set to display the next page and there is a delay, then the switch reads the variable and repeats.

My problem is how do I add a manual button to advance the display and change the delay (longer so it does not change on the user) The issue I am having a problem getting around is the delay, since it is in delay it is not reading the pin that advances the screen.

The IF statements are where I need the help.

Any suggestion would be appropriated.

void loop() {
// decide what to put on the display
switch (page) {
case 0:
//do something when var equals 1
vfd.clear();
vfd.print("Starting up...");
vfd.setCursor(0, 1);
vfd.print("System Monitior");
vfd.setCursor(0, 2);
vfd.print("Version 1.0");
vfd.setCursor(0, 3);
vfd.print("Bla Bla Bla");
page = 1; // set the next page to display
break;

case 1:
//Show page 1
vfd.clear();
vfd.print("Page #1");
vfd.setCursor(0, 1);
vfd.print("Time On -");
vfd.setCursor(0, 2);
vfd.print("VFD is WORKING");
vfd.setCursor(0, 3);
vfd.print("Zone 1 = ON");
vfd.setCursor(11, 1);
vfd.print(millis()/1000); // print the number of seconds since reset:
page = 2; // set the next page to display
break;

case 2:
//do something
vfd.clear();
vfd.print("Page #2");
vfd.setCursor(0, 1);
vfd.print("Header Temp = 181");
vfd.setCursor(0, 2);
vfd.print("Return Temp = 162");
vfd.setCursor(0, 3);
vfd.print("Burner is ON");
page = 3; // set the next page to display
break;

case 3:
//do something
vfd.clear();
vfd.print("Page #3");
vfd.setCursor(0, 2);
vfd.print(pin22);
page = 1; // set the next page to display
break;

default:
// if nothing else matches, do the default
vfd.clear();
vfd.setCursor(0, 1);
vfd.print("ERROR, No page Ref.");
}

// check for user selection of screens
if (pin22 == 1){
// the user has pushed the scroll button, advance the display page and set the delay to one min.
if (page == 1){
// make it 2
page = 2;
}
if (page == 2){
// make it 3
page = 3;
}
if (page == 3){
// make it 1, since we only have 3 pages
page = 1;
}
// now set the delay longer so the user can read the display
//delay(10000);
}else{
// set the default auto scrole delay
delay(8000);
}

}

  if (pin22 == 1){

Why would pin22 ever equal 1? Unless pin22 refers to a pin number, it's a lousy name for a variable.

My problem is how do I add a manual button

Define a pin that the switch is attached to (and leave the buttons on the shirt where they belong). Read the state of the switch pin on every pass through loop. Get rid of all the delays. Change the menu when the switch is pressed.

pin22 is the pin the switch is connected to.

If I remove the delays then the screen will only advance when the user pushed the "button" ]:smiley:
I would like it to advance on its own also.

But If I keep the delays it wont read the state of pin22?

pin22 is the pin the switch is connected to.

pin22 is a variable. The value might be the pin number that the switch is connected to, If the value is 22, that is not equal to one, is it? If the value is not 22, then the name is still bogus.

If I remove the delays then the screen will only advance when the user pushed the "button" smiley-twist
I would like it to advance on its own also.

Then, you still need to get rid of the delays. Look at the blink without delay example to see how to get rid of the sitOnYourHandsAndDoAbsolutelyNothingElse() calls (also known as delay()).

But If I keep the delays it wont read the state of pin22?

"It"? It is a pronoun without a proper referent. The loop() function will, eventually, read the state of pin 22, after all the delay() have expired. The key there is eventually. That is not what you want.

Thanks PaulS,
The "blink without delay" example was exactly what I needed. never thought to do it like that but an excellent idea!