Cortex light blink red when switch is pressed

So, I am a PLTW teacher, and some of my students are experiencing a weird bug. We are building drag racers that start with a push of a button, and stop when they travel 20 ft (as measured by an Optical shaft encoder). Here is the code:

task main()
{
	while (1==1)
	{
		if(SensorValue[bswitch] == 1)
		{
			SensorValue[encoder] = 0;
			motor[leftM] = 127;
			motor[rightM] = 127;
			while(SensorValue[encoder] <= 5000)
			{
			wait1Msec(1);
			}
			motor[leftM] = 0;
			motor[rightM] = 0;
		}
	}
}

Here is the problem. The program seems to work fine when the robot is tethered to the computer. But when you detach it and take it to the racetrack, the robot only works if the bump switch is held down. When you press it quickly, all the lights on the cortex flash red for a fraction of a second, but the robot doesn’t start. The robot will only start if you hold down the bump switch for about a second. To reiterate, this behavior only appears when the robot is untethered from the computer.

I am stumped. Does anyone else have any ideas?

From the description it sounds like battery voltage drops and the Cortex resets. When you are tethered to the computer you have a second power supply through USB cable that might be keeping Cortex running.

Some people had reporting shorted button switches causing 5v voltage regulator (that supplies power to sensors) overheating. However, that does not explain why holding button pressed for a second makes it work.

Try to decrease motor power from 127 to something like 40 and then see what happens if you hold robot off the ground while you are pressing the button.

Also, if you are using RobotC, check that you are using correct communication mode. I believe, you should have “USB Only” for what you are doing.
http://www.robotc.net/wikiarchive/Tutorials/Getting_Started/Getting_Started_with_the_VEX_CORTEX#Step_4:_Downloading_and_Running_Code

I just realized my response was irrelevant, so I deleted it. Sorry xD