# Turning the Drivetrain Using RUN\_TO\_POSITION

Often times, like in the program created during [Part 2: Robot Control](https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-2), we use the ![](https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FK4MBTQx223pX8GyGaZE1%2Fimage.png?alt=media\&token=7c68448d-5ad0-41a1-b5f2-a01670223f49) block to set the drivetrain motors to a set power or power based on a joystick's inputs. The combined power going to both motors help to determine the direction the robot moves or turns.&#x20;

However, in `RUN_TO_POSITION` mode the encoder counts are used instead of <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MVrZYOdMO43YdZ0zxXy%2F-MVwRA9auYOOqnGmzAX7%2FDual%20Motor%20-%20set%20to%20positive.svg?alt=media&#x26;token=ed171c16-63c4-4531-89f3-ed93ce36dbae" alt="" data-size="original"> to dictate directionality of the motor.&#x20;

* [x] If a target position value is greater than the current position of the encoder, the motor moves forward.
* [x] If the target position value is less than the current position of the encoder, the motor moves backwards.

Since speed an directionality impacts how a robot turns, target position and velocity need to be edited to get the robot to turn. Consider the following code:&#x20;

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FdSipS80K3ry4eRpOSJOZ%2Fimage.png?alt=media&#x26;token=c518311a-4117-4c62-b5e1-bbf79af174e6" alt=""><figcaption><p>Example encoder code with turning</p></figcaption></figure>

The `rightTarget` has been changed to be a negative target position. Assuming that the encoder starts at zero due to `STOP_AND_RESET_ENCODER` this causes the robot to turn to the right.&#x20;

Notice the velocity is the same for both motors. If you try running this code, you can see that the robot pivots along its center of rotation.&#x20;

To get a wider turn, try changing the velocity so that the right motor is running at a lower velocity than the left motor. Adjust the velocity and target position as needed to get the turn you need.
