Can someone please help me with coding my drivetrain to stop and lock the drivetrain motors when I press the button A.
Someone else will chime in with a fuller explanation, but to begin with you probably want “pressing” instead of “pressed” in your first if() statement.
And you probably want an “else” not an “else if”.
You might want to set a toggle for this behavior.
if (Controller1.ButtonA.pressing() { brakeToggle = 1 - brakeToggle; }
if (brakeToggle == 1 { pseudo code set all motors stop and brake hold; }
else { pseudo code set all motors to brake coast; }
and if you really need the behavior to brake only while button is being pressed, try…
while (Controller1.ButtonA.pressing) { pseudo code set all motors stop and brake hold; }
but the experts can correct me if I’m wrong. Good luck!
Thank You I will try that.
If necessary, you can use the pressing() function and build your own code that would do button presses. It isnt that difficult, if you are interested.
I got it working I just used the pressing function instead of the Pressed function.
Thank You for your help