Problems with Rotation sensor

I have been having problems with using the rotation sensor to make motors stop spinning when it reaches a certain point. This is an example of my code.

while(Rotation1.position(degrees)>157.67){
Lift.spin(reverse);
}

This is what you probably want to do, you need to slow the motor down before it reaches your target position proportionally. Motors/the robot have momentum and won’t magically stop and stand still after you stop applying voltage to it.

https://wiki.purduesigbots.com/software/control-algorithms/pid-controller

1 Like

You need to add Lift.stop(); right after the while loop. Otherwise, it doesn’t know that you don’t want it to keep going anymore.

2 Likes