> For the complete documentation index, see [llms.txt](https://guides.mccaskeyrobotics.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.mccaskeyrobotics.org/ftc/programming.md).

# Programming

To create a new program click on the + sign which you should find near the top left of your screen.&#x20;

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FwBwSZ1aPeIEPdYpCisdu%2Fimage.png?alt=media\&token=550591df-2f44-4cb6-920d-5986ef078efa)

Name your file. From the Sample code select `BlankLinearOpMode` and make sure to check the `TeleOp` Option.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FRMFht53gDbbOcrCgxm2k%2Fimage.png?alt=media\&token=8a108fcd-ec36-419d-a589-720e62446e9f)

After you hit `OK` Your code will look something like this:

```
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.util.ElapsedTime;

@TeleOp

public class BlankLinearOpMode extends LinearOpMode {


    @Override
    public void runOpMode() {

        telemetry.addData("Status", "Initialized");
        telemetry.update();
        
        // Wait for the game to start (driver presses PLAY)
        waitForStart();

        // run until the end of the match (driver presses STOP)
        while (opModeIsActive()) {
        
            telemetry.addData("Status", "Running");
            telemetry.update();

        }
    }
}
```

## Running your program

At the bottom right of your screen click on the wrench.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2Fgit-blob-63f97a8e1ca94d4ae853617678edb9429f3988b7%2Fimage2?alt=media)

Now open your DS app on your group’s phone and select the right-side dropdown menu. Now choose the program you just built.

Click “Init. You should now see a message on the bottom of the screen that says: “Status: Initialized”.Now click “Play”. You should now see the message on the bottom of the screen that says “Status: Running”.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2Fgit-blob-8475c1ba608d843c24012e2c8d07920e92b3e8f7%2Fimage11?alt=media)

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2Fgit-blob-e89cb5861907e4340f2b33d261f9c86197b3ba19%2Fimage1?alt=media)

{% hint style="success" %}
Congratulations you just wrote your first program!
{% endhint %}

You robot doesn’t do much yet.. Just send a message to the phone to tell you it’s status. Go ahead and hit the stop button to stop your program.

Before we start programming our drive motors, let’s take a minute to look at the structure of a opMode.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FC9sZXpv7aSfC7gSPggSR%2Fimage.png?alt=media\&token=705d67ce-b634-4166-a230-a3891fd8d8e3)

This Is a comment. A comment is the code between the `/*` and `*/` symbols. It is just there to help the person writing the code understand what it does. When the robot runs this program it will skip over this section.

{% hint style="info" %}
TIP: If you only need a single line comment you can add two slashes to the begining of that line.

Example:

// Wait for the game to start
{% endhint %}

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FPDbdgnVuBCXYFWKuaGsS%2Fimage.png?alt=media\&token=14fb6c32-71e9-442b-8863-2c5f12c1a54f)

Here is where we import other code that the robot needs to run. The robot should add these automatically so you do not need to worry about editing this section &#x20;

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2F2qsheI3PMpQKwmOKWlCU%2Fimage.png?alt=media\&token=0325ce63-223d-42d0-88dd-ea8681b4b680)

This line of code tells the robot where you have to go to run your program. You have three options for this line. @Autonimous, @TeleOp, and @Disabled. The main difference between Autonomous and TeleOp is that Autonimous had a 30s timer. Disabled will hide your program from the menu and is helpful if you have a lot of programs.

Shown below is where you can find your programs.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2Fg6rEyI5QDFJiAQyGmkmt%2Fspaces_jRgHmD322MUgRPOyqMLh_uploads_git-blob-8475c1ba608d843c24012e2c8d07920e92b3e8f7_image11.png?alt=media\&token=23a3f768-0927-44c2-b766-87de4f615b8c)

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2F5qk54UviCDFoBTSAydsj%2Fimage.png?alt=media\&token=8a60c672-24c0-4c98-a57f-bd5f77d3c1de)

These line are needed to run your program. Your class name MUST match your file name.&#x20;

Your program must extend eighter `LinearOpMode` or `OpMode`. OpMode is a bit more complicated so for right now just use LinearOpMode.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2F68y5TxHgLokIA6AYrLJz%2Fimage.png?alt=media\&token=a22b8f86-2e77-4794-a02b-bd03fd13c3f7)

telemetry is a way the robot tells you what it is thinking. When you use the code

&#x20;`telemetry.addData("Statius", "Initialized");`

The robot will save the information you gave it until you call&#x20;

`telemetry.update();`

which then sends it to the driver.

![](https://3423273789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjRgHmD322MUgRPOyqMLh%2Fuploads%2FPiDvckLIm7r22lLz3eke%2Fimage.png?alt=media\&token=577b4e1d-c4aa-434b-9094-fd005389456c)

This is a while loop it will repeat anything in side the curly braces until the program ends.
