> For the complete documentation index, see [llms.txt](https://docs.revrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revrobotics.com/first-global/code-examples.md).

# Using the Example Programs

{% hint style="info" %}
This guide shows where to locate the *FIRST* Global Blocks and OnBot Java example programs.
{% endhint %}

### &#xD;Prerequisite Reading

Prior to using this guide, you must understand how to connect the Driver Hub to the Control Hub and create a configuration file for the robot. If this is new to you, please read the [Introduction to the DUO Control System](https://docs.revrobotics.com/duo-control/) guide.

### &#xD;Program & Manage

Before programming, connect the Driver Hub to the Control Hub and make sure there is an active configuration file for the robot that contains any devices that you would like to be able to use from a program. See the [Configuration](https://docs.revrobotics.com/duo-control/programming/hello-robot-configuration) section of the [Introduction to Programming](https://docs.revrobotics.com/duo-control/programming/hello-robot-introduction-to-programming) guide for instructions on creating a configuration file.

Open the main menu on the Driver Station application in the Driver Hub and click on Program & Manage.

<img src="/files/TidOew4iXT3wBEi6Ebbd" alt="" width="563">

The screen will refresh, and then it will look similar to this screenshot. You will have a different network name. At this point, it is recommended to program using a Windows laptop with the [REV Hardware Client](https://docs.revrobotics.com/rev-hardware-client/) installed.

<img src="/files/1zxNUmhmJxkjPW79kSab" alt="" width="563">

For more information on how to access the Control Hub with a computer to program, check out [“Where to Program - Client vs. Browser”](https://docs.revrobotics.com/duo-control/hello-robot-blocks/where-to-program). The REV Hardware Client allows programming over Wi-Fi or a direct USB connection, however is only available for Windows computers. Browser-based programming must be done through a direct Wi-Fi connection to the Control Hub, but offers an alternative for other operating systems.

### Programming via a Windows Computer and the REV Hardware Client

Connect your computer to the Control Hub using a USB-C to USB-A cable. The USB-C, or oval end, will plug into your Control Hub, and the USB-A, or rectangular end, will plug into your computer. Once your Control Hub is connected and powered on, open the REV Hardware Client.

<img src="/files/bnefa8IDmEYKkxlnQZ6l" alt="" width="563">

Once you have navigated to the Program and Manage tab, you can choose between Blocks or OnBot Java.

<img src="/files/5MsfjAN4zettYkuS3xTY" alt="" width="563">

### Programming Tools: Blocks and OnBot Java

#### Program Using Blocks

Note: These images are from using a laptop to program. The screen layout on the Driver Hub is slightly different, but the icons and buttons are the same.

On the Main screen of the Blocks programming, click on the Create New OpMode button.

<img src="/files/v2E7mWIsmxXvThJ6aYvm" alt="" width="563">

Example programs are under Sample.

![](/files/N8YtGYcRv1VSfNQypcGw)

![](/files/nFlUEkKS7P4APDJPo8zr)

To open a sample program, first select a program and name the OpMode. Then click the OK button.

![](/files/NBCtwqJg8zdZ21ubJHgB)

The programming screen for Blocks will look like this. Ensure that your configuration/hardware map matches the sample program that you have selected. If you need help configuring your robot, read the [Hello Robot - Configuration](https://docs.revrobotics.com/duo-control/programming/hello-robot-configuration) guide.

<img src="/files/Yuwcy6KOLlR8jtJs8a04" alt="" width="563">

After creating your OpMode, click “Save OpMode” even if you need to make changes to your configuration. This will make sure the OpMode has been properly created and allow you to continue navigating to update or access other programs.

![](/files/YYMFaKDdblse6KqqvN6G)

For more information on Blocks programming, read the [Hello Robot - Intro to Blocks Programming ](https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-1)guide.

#### Program Using OnBot Java

Note that these photos are from using a laptop to program. The screen layout on the Driver Hub is slightly different. For OnBot Java, a computer is highly recommended in order to edit the code.

On the Main screen of OnBot Java click on the plus sign (+) to make a New File.

<img src="/files/ihklg5gwcRlLBGTzvB4I" alt="" width="563">

Example programs appear in the Example OpMode “File Type” in the right dropdown menu. There are many examples for OnBot Java.

![](/files/MWtVhSsblmuaBGOPwok8)

As of Robot Controller App version 10.3, you can now choose to create a blank template for OnBot Java or pick a sample code to use when getting started.

By default, when creating a new file, OnBot Java will show the file type as “Blank OpMode” with the option to select “Iterative” or “Linear” from the dropdown.

![](/files/hJ2WNZ3FdCNwfRu564Nn)

To use a sample program, first select “Example OpMode” from the “File Type” dropdown.

![](/files/CjXEiXzilLDLjSsNlDOa)

With this file type selected, the example programs are now available to view in the adjacent dropdown.

![](/files/la2itmnWcehP01o7zgsb)

Selecting one of the example programs will automatically fill in the “File Name” and “OpMode type” options. However, these may also be edited, if needed, to fit your team’s needs.

![](/files/yS62b9H1QrdoOHLo6L4p)

**Note**: Using a sample program in OnBot Java will disable the option to select “Add generated code for configured hardware”. When creating a “Blank OpMode”, there is a known bug in v10.3 with the “Add generated code for configured hardware” option not generating code as expected. Motor variables and the hardware map must be manually added.

This is the programming screen for OnBot Java. This screenshot is at the main Java Class of the program.

Make sure that your configuration/hardware map matches the sample program that you have selected. If you need help configuring your robot, read the [Hello Robot - Configuration guide](https://docs.revrobotics.com/duo-control/hello-robot-java/configuration).

![](/files/PnvKzBEHnH03BVKVqSkF)

For more information on OnBot Java programming, read the [Hello Robot - Intro to OnBot Java Programming](https://docs.revrobotics.com/duo-control/hello-robot-java/part-1) guide.
