# Moving to a Target Distance

Now that you have created the constant variables needed to calculate the amount of ticks per mm moved, you can use this to set a target distance. For instance, if you would like to have the robot move forward two feet, converting from feet to millimeters and multiplying by the `COUNTS_PER_MM` will give you the amount of counts (or ticks) needed to reach that distance!

Let's create two more variables called `leftTarget`  and `rightTarget`. Add the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MYeyIdN23s6PuxYRjxx%2F-MYfarkmXxKPyNxDquzZ%2FVariables%20-%20set%20leftTarget.svg?alt=media&#x26;token=c6637dac-56cf-46cd-bdc4-fadcf7e216d3" alt="" data-size="original">and <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MYeyIdN23s6PuxYRjxx%2F-MYfauhcXmBRK_CtexwM%2FVariables%20-%20set%20rightTarget.svg?alt=media&#x26;token=c3b16a3d-1f9c-4545-bd5c-486f5b242146" alt="" data-size="original"> blocks within the if/then statement that will run once Play is selected.

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2F5xnzHxBLOtwN6F4heGLg%2Fimage.png?alt=media&#x26;token=31db86a1-0a11-4558-9303-3f707d27de9f" alt=""><figcaption><p>Inserting our leftTarget and rightTarget variables</p></figcaption></figure>

### Converting from mm to Feet

Right now the main distance factor is `COUNTS_PER_MM` , however you may want to go a distance that is in the imperial system, such as 2 feet (or 24 inches). The target distance in this case will need to be converted to mm.&#x20;

To convert from feet to millimeters use the following formula:

$$
d\_{(mm)} = d\_{(ft)} × 304.8
$$

If you convert 2 feet to millimeters, it comes out the be 609.6 millimeters. For the purpose of this guide, lets go ahead an round this to be 610 millimeters.&#x20;

### Converting Feet to Ticks

Next, multiply 610 millimeters by the `COUNTS_PER_MM` variable to get the number of ticks needed to move the robot 2 feet. Since the intent is to have the robot move in a straight line, set both the `leftTarget` and `rightTarget`, to be equal to 610 \*  `COUNTS_PER_MM`

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FazT8n403FCCpgChE3oFC%2Fimage.png?alt=media&#x26;token=73ab2dd6-8d77-4a4f-95b3-f9aac7950524" alt=""><figcaption></figcaption></figure>

Lastly, we need to change the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MYCCC1UjXUUSq0ujDmk%2F-MYGq13GHps2CyeLWbZt%2FDual%20Motor%20-%20target%20position%20to%201000.svg?alt=media&#x26;token=6c977583-8da8-43a2-848e-0b09583f63d4" alt="" data-size="original"> so that both motors are set to the appropriate target position. To do this add the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MYeyIdN23s6PuxYRjxx%2F-MYfkdJjHrXQM9Phg8gz%2FVariable%20-%20left%20target.svg?alt=media&#x26;token=a74c319c-7899-4316-b980-7faf93a1327b" alt="" data-size="original"> and <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MYeyIdN23s6PuxYRjxx%2F-MYfkhOc5yahjvtzUAq2%2FVariable%20-%20right%20target.svg?alt=media&#x26;token=5b5a09bb-1a64-4829-9151-afe48cbebf32" alt="" data-size="original"> blocks to their respective motor.&#x20;

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2Ffg7Tl4ijUctS1icKK5lF%2Fimage.png?alt=media&#x26;token=494b9de9-cb9e-4105-9d06-8e73ebd7b017" alt=""><figcaption><p>All of the blocks added to set a target distance</p></figcaption></figure>
