Motor Lock Programming

I currently have a brake on the bottom of my robot that lifts the rear end of the chassis up slightly to prevent the robot from being pushed off of the platform. The only problem I am facing now is programming for the motors attached to my omni-wheels. I want to program the driver control so that if I press a button when I am on the platform, the base motors will set to brake or “lock up.” Does anyone know how I could do this?

Well, you could set the original BrakeType outside of the While Loop, then have an if statement setting it to the holding BrakeType. But then you would also want to have an else if statement to change it back, just in case you accidentally toggle it you’re not stuck in that mode.

I programmed a similar function for our robot. This is the statement that I used

if (Controller1.ButtonDown.pressing() == true){

So our driver just holds the down button when he is on the platform and it holds all of the motors in place.

Sweet, thank you! This will work great in tandem with our brake system.

Or you could combine these solutions so that the driver doesn’t have to hold the button. It would allow for more versatility both on and off the platform.

@Got a Screw Loose Right, you could use two if statements connected to two separate buttons, one for setting the brake type to hold, and the other for setting it back to coast.

Im sure there is a more clever way of doing it, but that would probably be the easiest.

I tried ChanceJewell’s program and it worked well, but after I press the button, and I try and drive, it doesn’t switch back to the coast setting. How do I fix this?

Am I doing something wrong within my program? Here’s what I have. I’ll drive it, and the motors will be set to coast, then after I press the Y Button, it does hold, but when I drive it after I let go of the button, it drives, but it is in brakeType hold so it jolts when I drive it.