Program for pauses in autonomous using bumper switch?

I am looking to create a program that will stop mid autonomous and wait for a bumper switch to be pressed, and continue with the next section of code. This would be useful so that I can reposition the robot by hand during the pause, and not have to worry about a specific wait time. If any one knows how to help, it would be greatly appreciated! Thank you!

There is a sample program in ROBOTC that you can use to perform this behavior (File → Open Sample Programs → Bumper & Limit Switches → Wait for Push.c)


//Stop motors

while(SensorValue(touchSensor) == 0) //Loop while robot's bumper/touch sensor isn't pressed in
	{
		//Do nothing
	}
wait1MSec(50);

while(SensorValue(touchSensor) == 1) //Loop while robot's bumper/touch sensor is pressed in
	{
		//Do nothing
	}
wait1MSec(50);

//Next behavior

This is a modified version of the code. What this code does is first loop through an idle loop (which executes no new code but simply holds the program flow at that loop while the condition is true) while the button is not pressed. When the button is pressed the value of the first condition becomes false and the loop exits.

The next behavior is a 50ms wait command; this is to accommodate for debounce in the switch.

The next while loop holds the program flow while the switch remains pressed, and adds another 50ms ‘debounce’ wait command once the button is released.