Rotating for a Potentiometer Value [C++]

Hey guys,
My team is using a catapult and we have a potentiometer on it. How would we make it rotate for a specified amount of degrees/to a certain point ON THE POTENTIOMETER? Please link any related posts below as well. I found this: but the link given is expired. Thank you in advance!

UPDATE: The link isn’t expired, but the discussion eventually ends.

If you are using V5 it would make a lot of sense to use the motor to sense its rotation angle with the rotateFor method. You are likely to have geared that component for torque, but can just multiply the desired angle of arm rotation by the gear ratio to get how many degrees the motor needs to rotateFor in order for the arm to move the correct amount.

looking at you can access the value with potNameHere.value(rotationUnits::deg).

If you wanted to just get sort of close (and ignore the built in processor, sensors and pid on the motors):

void setCataDegrees (int targetDegrees)
while (cataPot.value(rotationUnits::deg) < targetDegrees)
//run the catapult motor in a direction that increases the cataPot.value
task::sleep(20); //wait a bit before checking pot value again 
cataMotor.stop(braketype::hold); // hold position

This function would prevent you from doing other things while the catapult is moving to the desired location… so you might want to look into a task instead.

Be aware the pot can only rotate in a limited range (~160 degrees) .