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?