# Programming - Main Loop

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FdXPMOzF8AK9S1YFyvyVl%2Fimage.png?alt=media&#x26;token=3e3769a8-8dca-4132-a849-359a10a403db" alt=""><figcaption><p>Main loop for the TeleOp code</p></figcaption></figure>

The main "whileLoop" of our program this year is fairly short containing our functions and temeletry for the flywheel.

## What is a Function? <a href="#what-is-a-function" id="what-is-a-function"></a>

You can think of functions (also known as methods) as a set of pre-written instructions represented by one line of code. When the function is called, the robot knows to run that set of instructions.

As an example, in our program we've created a function called splitStickArcadeDrive. Any time the robot receives an input for that function, in this case from the joysticks, it knows to go through the process of running the drivetrain despite those code lines not being listed individually in the mainLoop.

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2F8NUgo5ruHZEm6L0jzdEu%2Fimage.png?alt=media&#x26;token=99bdbd42-e334-4793-8f28-366f706e5a15" alt=""><figcaption><p>splitStickArcadeDrive function being called in the mainLoop</p></figcaption></figure>

Our full splitStickArcadeDrive function, and those code steps, can be found elsewhere within our program organized and self-contained with all the relevant pieces together. This code is what's run when the function is called.

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FHoDGOH3E4f0Tsg0pc3Yo%2Fimage.png?alt=media&#x26;token=fd426495-5d47-4f24-890f-4d2cbf05ca07" alt=""><figcaption><p>splitStickArcadeDrive function</p></figcaption></figure>

**In short:**&#x20;

Functions take the place of several lines of code and appear as a single line when called. This can be incredibly useful if there is a section of code we know will be repeated or to break apart our code into chunks for easy editing and viewing.

Below is a breakdown of our functions

<table><thead><tr><th width="272.8887939453125">Function</th><th>Purpose</th></tr></thead><tbody><tr><td>splitStickArcadeDrive</td><td>Contains the code for driving the robot</td></tr><tr><td>setFlywheelVelocity</td><td>Contains both the auto and manual control for the flywheel</td></tr><tr><td>manualCoreHexAndServoControl</td><td>Contains manual control for the feeder Core Hex and servo</td></tr></tbody></table>

{% hint style="info" %}
Interested in learning more about functions? [Check our Hello Robot!](https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-4-going-beyond/exploring-functions)
{% endhint %}

## Telemetry

The telemetry of the main loop reports the flywheel's velocity and how that equals to power. This can be used as a reference when troubleshooting the flywheel or determining if a new velocity target should be set.&#x20;

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FuL7iI5HiAmKZactODxht%2Fimage.png?alt=media&#x26;token=19a0b2da-fd6b-4879-87fa-ecc1dd2c0773" alt=""><figcaption><p>Telemetry for the flywheel's velocity and power</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.revrobotics.com/ftc-kickoff-concepts/decode-2025-26/programming-teleop/programming-main-loop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
