Skip to main content
Materials Required:
Quantity Materials Needed
1

VEX V5 Classroom Starter Kit (with up-to-date firmware)

1

VEXcode V5 (latest version, Windows, macOS)

1

Engineering Notebook

1

Tank Control example project

2 or more

Classroom items to be used as obstacles

This activity will give you the tools to program your Controller.

Step 1: Let's start programming the Controller.

  • Open the Tank Control example project.
  • Example Project Icon of a tank positioned above a game controller, with the label 'Tank Control' beneath it.

    Do the following in your engineering notebook:

    Predict what this project will have the Clawbot do. Explain more than the fact that the project utilizes the Controller.
    How do the joysticks move the robot? What is the Clawbot doing?

Code example for controlling a robot using the VEX Library in C++. The code includes the VEX library (#include "vex.h") and sets up a loop where the left and right motors' velocities are continuously updated based on the positions of Controller1's Axis 3 and Axis 2, respectively. The motors then spin forward at these velocities. The loop includes a brief delay of 5 milliseconds (wait(5, msec);) to ensure smooth operation.

 

  • Save, download, and run(C++) the Tank Control example project.
  • For help check out the VEX Library sections on C++ or see the tutorial in VEXcode V5 that explains how to Download and Run a Project.

    Toolbar in VEXcode V5 with Tutorials, to the right, highlighted with a red box. From the left, the Toolbar shows a V5 logo, a globe icon, then File, Edit, and Tutorials.

     

  • Check your explanations of the project in your engineering notebook and add notes to correct them as needed.

Step 2: Controller: Tank Control

​What are the benefits of using the while True infinite loop structure?

Here is our project without the while True infinite loop structure:

Code example demonstrating the use of the VEX Library in C++. The program includes the necessary library and namespace declarations, and then enters a loop where it continuously reads the positions of Controller1 Axis 3 and Axis 2. These values are used to set the velocity of the left and right motors, respectively, which are then spun forward at those velocities. A brief wait of 5 milliseconds is included in the loop to ensure smooth operation

What do you think would happen if this program were run? Discuss as a group. Write down your prediction in the engineering notebook.

Step 3: Navigate a Slalom Course!

A snowboarder is racing downhill on a snow-covered slope, navigating through a series of red and blue gates positioned in a zigzag pattern.

Slaloms are courses which the participant must navigate around the set flags, or markers. Ski slaloms are a popular winter sport and are included in the Winter Olympics.

Now that the Controller is paired and the C++  project is downloaded, you are ready to move your Clawbot using the Controller!

  • Collect the four classroom items you will use as flags in your slalom from the teacher.
  • Collaborate to set the flags in place for the Driver to navigate the Clawbot around, according to the slalom diagram.
  • Download the Tank Control Example project. If there are any questions about how to download a project, check out the Download and Run a Project tutorial.

Step 4: Robo-Slalom

An illustration of a slalom course on snow, with a 'Start' label at the top, and a Finish line at the bottom. Between, a dotted zigzag path weaves between alternating blue and red flags.

Use the Controller to move your Clawbot along the outside of each “flag.” The robot’s path must prevent it from touching any flag, and allow it to cross the finish line.

  • Run the project and drive the Clawbot forward and reverse, and turn left and right using both Joysticks.
  • Time how long it takes for the Clawbot to complete the course. Document the times in the engineering notebook.
  • How fast can you get Clawbot through the Slalom course?