# ElapsedTime Setup

### Locating ElapsedTime Blocks:

Before getting started, let's quickly identify where we will find our ElapsedTime blocks. This menu can be found under the Utilities dropdown on our side toolbar.

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2F7uW7hj95zzbIjhqAiDGJ%2Fwheretofindelapsedtime.PNG?alt=media&#x26;token=a750c3f9-8c86-481f-8e91-2d11388d4777" alt="" width="152"><figcaption></figcaption></figure>

### Setting up the Basics:

For this section, let's start by creating a new OpMode named HelloRobot\_ElapsedTime using the BasicOpMode sample.&#x20;

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FfF7q3gMIlLNOEEgH7XET%2Fhellorobotelapsedtime.PNG?alt=media&#x26;token=948e0c35-a79f-4227-898d-4635a7db049b" alt=""><figcaption></figcaption></figure>

Recall when we [created variables while programming our drivetrain](https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-2/arcade-style-teleop-blocks/establishing-variables-in-blocks). We will be using them again during this part to help with calculations! To start create a variable called **runtime**.

![](https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MRQ9yIkxBieLbHHoHvx%2F-MRQE2gij3X-3R0XTgtw%2Fcreate%20new%20variable.svg?alt=media\&token=8b54cd20-ee50-44f3-afb3-0bae1da2aebb)

From the variable menu, add the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MW6-jSLF6Z7O0wWozgO%2F-MW6E-QPblWZt1LMlC9-%2FVariable%20-%20set%20runtime%20to.svg?alt=media&#x26;token=03cddd91-5388-4f24-9b13-5e9ce7f720c6" alt="" data-size="original"> block to the OpMode below the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MVIIB5oT9i9P2l29VHj%2F-MVRzzz2RWu0i_oNzqo3%2FComment%20-%20Put%20intialization%20blocks.svg?alt=media&#x26;token=5b100e29-9c67-4bb3-be74-0d35d452cb76" alt="" data-size="original"> comment block.&#x20;

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FCu0anCf7YpdQ5lWP1zB7%2Fruntimevariable.PNG?alt=media&#x26;token=c34cfb64-0dcf-463d-9a4d-2e4d4106f5fb" alt=""><figcaption></figcaption></figure>

In order to utilize elements of the ElapsedTime, runtime will act as the **ElapsedTime** variable.  Add the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MW6-jSLF6Z7O0wWozgO%2F-MW6Id3RUFs-McuyZkjF%2FElapsedTime%20-%20new%20ElapsedTime.svg?alt=media&#x26;token=20afae34-23e2-42b6-b638-d2445d265e56" alt="" data-size="original"> block to the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MW6-jSLF6Z7O0wWozgO%2F-MW6E-QPblWZt1LMlC9-%2FVariable%20-%20set%20runtime%20to.svg?alt=media&#x26;token=03cddd91-5388-4f24-9b13-5e9ce7f720c6" alt="" data-size="original"> block.&#x20;

![](https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MRQ9yIkxBieLbHHoHvx%2F-MRRF-G8F9erACtpn8C1%2Fruntime%20is%20qualt%20to%20new%20elapsed%20time.svg?alt=media\&token=d39cd920-775b-404b-a394-896445203302)

Before moving on to the rest of the ElapsedTime structure lets go ahead and add the motor related blocks. Add <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 the op mode to the while loop.

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2FkKL0exXkr5YKxZK3xbmt%2Faddingpowerelapsedtime.PNG?alt=media&#x26;token=38d3607b-65af-4681-9fe2-0c4e5ab9dd59" alt=""><figcaption></figcaption></figure>

Remember that on a drivetrain one of our motors will need to be set to run in reverse to prevent the robot from spinning in place! Add the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MW6-jSLF6Z7O0wWozgO%2F-MW6L1g4Y8GSBICwwFHF%2FMotor%20-%20rightmotorDirection.svg?alt=media&#x26;token=67d93d39-a4fd-441f-ae5d-6d323d657c6c" alt="" data-size="original"> block under the the <img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4_pJHI8HTuZFQTNfcy%2F-MW6-jSLF6Z7O0wWozgO%2F-MWA6F39D-6nHYXTbLoY%2FElapsedTime%20-%20set%20runtime%20to%20new%20ElapsedTime.svg?alt=media&#x26;token=e2db2476-668a-4353-886b-93fb97093da4" alt="" data-size="original"> block set.&#x20;

<figure><img src="https://1359443677-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUOOiQ4S2QcMWmVoSmeQ8%2Fuploads%2F1gVbTugg9SEP2B16jFoO%2Fimage.png?alt=media&#x26;token=94d5e802-68e6-43eb-b2ad-5d9926ffe839" alt=""><figcaption></figcaption></figure>
