Getting bumper to turn motors off


I am doing a bumper bots project with my students and I am unable to use the bumper switch to turn off the motors. I have tried EVERYTHING!

We used to this with much success:

This no longer works, I’m figuring something changed with the latest app update. I can’t seem to find any way to use input from the bumper to immediately switch off the motors. Could someone help?

We made some changes to the drivetrain based on your feedback in this topic from last year.

The code above is trying to do two things based on pressing a single bumper switch. In the blocks on the left, you detect the press and then enter a forever loop asking the drive to move forwards and then turn right. This event handler will only fire once as it contains a forever loop and never completes. The blocks on the right will detect the press and try to stop the drive, the problem is that the left group of blocks that is still running will start it again.

In the older version of VEXcode, it may have been possible for the stop drive to take effect, it would have depended on whether the drive was performing the drive forward or turn right move and whether a gyro was being used. If the drive was stopped, the code on the left may have been stuck in, for example, the drive forward block, you could not restart the drive again while this condition existed, that was I think the original problem back in November.

The newer version of VEXcode will detect this condition and abandon any drive forward or turns that a drivetrain may be performing when stop driving is sent. However, because you have those blocks inside a forever loop, the code will just move on and perform the next drive or turn command.

One solution would be to use a boolean to indicate the current action, driving or stopped. There’s more than one way to do this, here is one possible solution that would start and stop the drive based on the bumper switch, it starts with the drive disabled.



This worked! Thanks SO much!