Vexcode Limit Stop/Soft stop

Hey guys as you know I use vexcode. I was wondering how to make the motor stop at a certain degree when you hold down the button and no matter what it will stop at that degree. Kinda like a safety stop so you don’t break your arm or something.

1 Like

you mean like a limiting angle? There are a few ways to do that but the main idea would look something like this:

if(buttonpressing && sensordata < maxAngle){
    control the motor normally
}
else {
    control motor only in the direction away from the max angle
}
4 Likes

There are two sensors you can use: potentiometer and the limit switch.

Limit switch is simpler to get started with. Potentiometer is more advanced and many teams use it to program PID on their lifts for autonomous.

https://www.vexrobotics.com/276-2216.html

2 Likes

Ok I am using V5 which means it can tell what angle it is at like a Potentiometer.

Uh what is the control the motor normally? Is that code or just you. Could you make a real example… I am kinda lost here.

It means like running the motor. What he posted was pseudocode.
What you would put instead is:
Motor.spin(forward,100 percent);

You can tell the angle with V5 motor encoders only if you know in which position robot started.

You can gently run your arm into hard stop at the beginning of the program to find zero or use a limit switch.

This is code example:

2 Likes

So what would I put in the fill in blanks. I dont understand what is what. Like I said could I get a real example to go with. I am pretty new to this.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.