How do I make my motor spin a certain amount of degrees in c++

I know how to make it spin I just don’t know how to insert the amount of degrees.

Try using one of the other spin methods, eg spinToPosition() - that one sends it to an absolute value (if you want relative position you would sample the current value first).

You are in the RobotC channel so I am assuming that you are not using V5. The V5 motors have integrated motor encoders but the RobotC, Cortex, 393 motors do not.

You would need to use a sensor to measure the motor rotation. One option is with the Optical Shaft Encoder here: Optical Shaft Encoder (2-pack) - VEX Robotics

Let’s start with what programming language you are using. You’ve tagged ROBOTC support, but your question mentions C++, which could refer to Vexcode Pro V5 or PROS. Which one are you using?

4 Likes

sorry I am in vexcode pro

Use the spinTo function as seen here

motor.spinFor(100, degrees);

Simple answer. In this example the name of the motor is Motor1

Motor1.spinFor(forward, 90, degrees);

ok thanks it works now