# Let's get Spinning!

The telemetry block from the last section can be removed from our OpMode.&#x20;

## DC Motors

Let's start by getting our Core Hex Motor spinning on the testbed. Under the **Actuators** menu look for **DcMotor**:

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FKIMSwKJteGaiuwmrqTJA%2Funknown.png?alt=media&#x26;token=7c04d7fb-ec91-4ec2-b685-1aab39294d70" alt=""><figcaption></figcaption></figure>

When looking at the options, the names of the motors will typically appear in alphabetical order. In the pictures used for this guide coreHex shows as the default option. If you named your motors differently, there will be variation.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FFuXtksgMCep46wplBkPS%2Funknown.png?alt=media&#x26;token=8c32c5f4-67f8-4140-89c4-111ff818b2f7" alt="" width="401"><figcaption></figcaption></figure>

First, we'll add a power block to our loop:

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2F7hx0Qhe53ga7V23VpNOV%2Funknown.png?alt=media&#x26;token=e658de85-c252-44bb-92ad-f484e18587d3" alt=""><figcaption></figcaption></figure>

With that we can save our program and run it to see what happens!

### Changing Power Level

The max power for spinning forward is 1. The max power for spinning in reverse is -1. Going above these values will not make the motor spin any faster. However, it also will not damage the motor so students can be encouraged to explore what happens!

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FdvEHARqQ8QjBbIS9uceV%2Funknown.png?alt=media&#x26;token=90cbb23f-856d-41d4-a71e-f085e80eab2a" alt=""><figcaption></figcaption></figure>

Take a moment to try adjusting the power of the Core Hex motor then add the HD Hex Motor to spin in a similar fashion.&#x20;

The HD Hex Motor's name can be selected from the dropdown on the power block.

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FqlqK6NTZFE4FEbKBvKve%2Fimage.png?alt=media&#x26;token=569b7ac7-8956-4b24-b525-79f2f598ff47" alt=""><figcaption></figcaption></figure>

<details>

<summary>Code Example</summary>

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FEyF1chrFEzSiarfF0wv5%2Fimage.png?alt=media&#x26;token=4bfa906d-6034-4cb4-a898-d2c06ae43c64" alt=""><figcaption></figcaption></figure>

</details>

## Servos

While in angular mode, servos are programmed a little different than motors. Rather than assigning a power, we'll be setting positions for them to move between.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FoRmnFKxeWc4vmxoL4dyA%2Fimage.png?alt=media&#x26;token=3f7014ee-64d7-47fe-a4e6-aaa524840de6" alt=""><figcaption></figcaption></figure>

**Note:** This menu will appear differently if there is a continuous servo listed in the current configuration file.&#x20;

When looking at the options, the names of the servos will typically appear in alphabetical order. In the pictures used for this guide **servo** show as the default option. If you named your servos differently, there will be variation.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2F0S2wOse4KpGtW6ELUzAM%2Fimage.png?alt=media&#x26;token=eb0d5f1c-853e-416e-bf86-4754382f40f1" alt=""><figcaption></figcaption></figure>

Let's start by adding a block to set our servo's position to 1.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FQVJHME8hrUUOssMK0xkO%2Fimage.png?alt=media&#x26;token=03674332-391a-4fd5-b418-9bfc8733e874" alt=""><figcaption></figcaption></figure>

With that we can save our program and run it to see what happens! After running the program once, stop and try to run it again.

<details>

<summary>What happened?</summary>

Likely, the servo moved once to the new position then didn't move again when the program was reset.&#x20;

It is possible the servo did not move at all if it happened to already be at what it considers "1". Try a different position value then test again.

</details>

#### Resetting to Zero

If we want our servo to move each time our program runs, we need it to first reset to a different position. In this example, we can do this during initialization. &#x20;

Add a position block for 0 under **Put initialization blocks here**.

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FrGUlDOHhyyrtuA5ox1js%2Fimage.png?alt=media&#x26;token=9ba8dfd4-4123-4d86-ad5c-5570fe037d6f" alt=""><figcaption></figcaption></figure>

Now save the OpMode and run the program again.&#x20;

<details>

<summary><strong>What happens differently?</strong></summary>

When initializing, likely you saw the servo move to its 0 position, then once play is pressed it moves back to 1 again.&#x20;

</details>

Take a moment to try different positions for your servo to move between.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FtAbYYGFVPdIXuLIgQZMM%2Fimage.png?alt=media&#x26;token=07f03186-38f5-44d2-8685-c740d8dc915d" alt=""><figcaption></figcaption></figure>

In the next section we'll add a gamepad to control the movements of our actuators!
