Bumper program only works when USB connected

My bumper program works with the USB connected, but stops when the bumper is activated. I have a program that moves the robot forward until the front bumper is activated, then it moves backwards until the back bumper is activated, and so on. When the robot is connected via USB, the program runs fine, but when I disconnect and restart the program, the robot moves forward until the bumper is activated. Then it stops for a second or 2 and then moves forward again. When the front bumper is activated, it stops again.

What would cause the program to work fine when connected by USB but not when disconnected?

I have tried 2 other controllers, different bumper switches, and different digital inputs. What else might work?

Can you post your code?

They’re shouldn’t be any difference between USB and VEXnet, but you might be losing connection. Do all the lights on the controller stay the same when the robot gets stuck?

I didn’t think there should be a difference either, but the same problem happened with 2 different robots. The lights are green when it starts, but once the bumper is pressed and the wheels/motor stop, the Vexnet light turns yellow or red.

I think your VEXnet key has a bad connection. Can you use a piece of tape to hold it in place and see if your program works then?

If you are using ROBOTC then make sure you are not downloading as “USB Only”, choose either “VEXnet or USB” or “Competition” in the Robot->Vex communications mode menu.