1.) You're not changing programs, you're changing functions
2.) Don't use while loops for running functions - they will block your code
3.) See BlinkWithoutDelay
4.) "A loop of loops in a loop" is absolutely terrible for performance on a low-power MCU
You cannot do that. For one thing you can only have one setup() and one loop() function in a program
If you want your functions to behave as if they were in loop() so that the code is called repeatedly then you need to call the function repeatedly from loop().
You can do this by setting a variable to different values using the input button and calling the function associated with the current value. Basically you replace the Serial.print()s in the code in reply #3 with calls to your functions
The functions can be on separate tabs of the IDE if you want, but in order for the program to remain responsive to inputs they must not contain any blocking code that would prevent frequent reading of the input
case 0:
Serial.println("PGM1");
PGM1();
// or, just put all the PGM1 code right here
break;
case 1:
Serial.println("PGM2");
PGM2();
// or, just put all the PGM2 code right here
break;
case n:
//-----------
void PGM1()
{
PGM1 code
}
void PGM2()
{
PGM2 code
}
void n