Running Different Functions One at a Time

I have an alarm clock sketch, temperature sketch and some other sketches, and I would like to be able to push a button and select each different one. I know how to program the button stuff, but I don't know how to turn one function off and run another and keep it looping until I push the button to interrupt it to run another function.

Thanks, Russ

It depends how the existing functions and sketches are structured. It is likely you'll have to rewrite parts of them. But that's just a guess.

Use some menu system to select one program from a list to run. While running the program, keep an eye on the buttons and return to the menu if a button is pressed.

Here is a Morse code program I wrote. Several functions are in the program and they run when I select one of them on a menu.

You need to implement a state machine. At the top level you check the buttons and work out what function should be running as a state variable. Then you call that function. The functions must return after a short time in order for the buttons to be read again. Therefore your functions must also be structured as a state machine. This is what I did when writing the Dice game software.