obviously the pause and stop commands will have to run during the void loop() part of the code and opt 1, 2 & 3 could run in the void setup() part of the code. The pause function will have to not interupt the current ram cycle.

The code waits until you press a button. When you press the button it times how long you press it for. If it is longer than a certain time then it 'selects' that option, if not then it moves on one option.

void Menu(){ //starts the menu subroutine from being called in setup LCDclear(); //clears the LCD LCDserial.print("Program Menu"); //prints to the lcd on first line LCDsecond(); //prints to lcd on second line etc... switch (programnumber) { //reads the program number (set as 1 in setup) case 1: //displays the first menu item LCDserial.print("Race Timer"); LCDthird(); LCDserial.print("Track: "); LCDserial.print(distance); LCDserial.print("m"); break; case 2: //displays the second menu item LCDserial.print("Reaction Tester"); break; case 3: //displays the third menu item LCDserial.print("Calibration Mode"); break; default: //if errors then it goes to default item is the race code. LCDserial.print("Race Timer"); LCDthird(); LCDserial.print("Track: "); LCDserial.print(distance); LCDserial.print("m"); }

LCDserial.print(0xFE, BYTE); //Command code LCDserial.print(226, BYTE); //Goes to specific point to display code LCDserial.print("Next >"); //next code in specific position while(digitalRead(starterbutton) == HIGH){} //while button is high do nothing: {} (helps with debounce after button has been pressed) delay(5); while(digitalRead(starterbutton) == LOW){} //wait until button has been pressed (taken high). menudelaycount = 0; //clear menu delay while(menudelaycount <500){ //do this code within the 500 limit (over 500ms because of other stuff that is done and takes time) delay(1); menudelaycount++; if(digitalRead(starterbutton) == LOW){ //if the button goes low (button released) within this loop then it advances one menu option programnumber++; //increase the menu option if(programnumber > 3){ programnumber = 1; } Menu(); //then run menu code from start: the change in program number makes it change the option it is on. } } switch (programnumber) { //if the button is not let go within the menu time stated above then it does not loop back and then selects the subroutine from this switch case: case 1: Race(); break; case 2: Reaction(); break; case 3: Calibration(); break; default: Race(); }}

The switch is held low by a pulldown resistor, it waits until it is low (in case someone is holding the button), then it then waits for a button press. When it senses a button press, it starts a looping routine for 500 (not milliseconds due to other things that happen apart from the delay(1); ).If the button is let go within that time (normal quick press), it advances the menu item on. If it is held the whole time then it takes the program number, gets to the end of the code and runs the selected program.

You probably want to do it with an up/down menu on your 16x2 rather than the 20x4 serial LCD I did it on but the code could be pretty similar.

If you wanted to do it up/down/select then that should not be too difficult either.Assign each program part a seperate sub-routine and a number, then display the first 2 programs (numbers i and i+1), if you press the down button, advance the i value and run the display routine again. If you press the up button, decrease the i value (unless it is 1) and run again. Upon select button press, read the program number and run a switch case routine to select the corresponding sub-routine.

Just ignore what I said before about one button.Do you want to have 3 buttons, one left, one right and one select?Do you want to have 3 buttons, one up, one down and one select?Or do you want a single scrolling menu on one button (seperate screen change for each item or scrolling up/down?)

The only reason why I used the one button was becuase I was short on I/O pins. If I had had more pins then I would have done a better menu which scrolled up/down, with 3 buttons

If you want a scrolly up down menu then this is what I am thinking. It will also help me with coding a scrolling menu on my 40x4 LCD so I'm not just doing it for you

After one press of the down button:----------------------------------Fill DelayRam Delay <----------------------------------

After the next press of the down button:----------------------------------Ram DelayRam Pulse <----------------------------------

If you then press the up button:----------------------------------Ram Delay <Ram Pulse----------------------------------

If you get to the botton of the menu:----------------------------------Stop <--------------------------------------------------

Maybe make it so if you get to the top it cycles back round to the start..

What do you think?

The code you posted has a load of errors so I am not going to try and correct it at the moment.You have the basics but I think the type of menu I described above would be more suitable.If you just want a single button (but not so obvious as to how to use) menu then I can sort out that code for you.When I get home, I will also have my serial LCD to play on and test with.