Lock the motor?

We use vexcode pro v5 as editor.
In this season,We want to lock the motor as a lift limit.
But in the autonomous period and driver control period interval or before the autonomous period,
I don’t know how to program.
So,how to program or it’s impossible to implement.

I assume by locking the motor you mean not allowing it to spin. There are three break types: coast, brake, and hold
The default is coast, but you probably want your lift on hold.

This code should do it, but I am doing it off the top of my head so it might not work:

motorname.setBrakeType(hold);

3 Likes

We have the lifts on our robot right now to brake. I didn’t code it so I can’t help you there but I do want to say it makes your lift jerky. Don’t expect a smooth stop to the lift. It works well but that is a con of the motor braking.

1 Like

Are you using a sensor to know when to have the motor stop, or are you just using what is in the motor?

If I am reading this right, you are looking for where to set the limit for the motor. There is something called a pre auton function. You could state something there to have it stop. The pre autonomous function is to define things before the match even starts.

2 Likes

I’m using Encoder in motor

Thanks.That’s one of the things I need!
And how to stop between the autonomous period and driver control period.(When the referee calculates the autonomous period score)

1 Like

This is controlled by the field controller, so all you need to do is make sure you put your auton under autonomous, and driver under driver control.

Just set it so when the motor reaches a point that it will brake.

2 Likes

While being an effective way to stop the motor, it wouldnt be a very good method. I recommend you brake the motor instead. :slight_smile:

3 Likes

Eh, like you don’t have a pile of broken motors :upside_down_face:

1 Like