Skip to main content
Teacher Portal

Controllers and Loops

In competitions, teams must manipulate their robots wirelessly with controllers. The controller is programmed to update the robot based on input from the user. Loops are used in the project so that the robot repeatedly checks for updated input information. Loops allow the project to rapidly check which buttons have been pressed, or how far joysticks have been pushed. Once checked, this information is quickly relayed to the robot so that it responds quickly to the controller's instructions.

The following image shows the Tank Control example project from VEXcode V5. The while True infinite loop in this project checks the positions of Axes 2 and 3 forever in order to set the velocity of the motors.

A Python code snippet for a VEX robot program that continuously sets the velocity of the left and right motors based on the positions of Controller1 Axis3 and Axis2. The code spins the motors forward with the set velocity and includes a 5-millisecond wait time after spinning the motors. The code runs inside a while loop, ensuring continuous operation
Tank Control example project from VEXcode V5

Loops are important even for autonomous programming without a controller. A loop helps to simplify and organize repeated commands within a project.

Extend Your Learning icon Extend Your Learning

To expand this activity, ask your students to explore the differences between arcade control and tank control. Students can follow the example projects found in VEXcode V5.Image of the file menu open in VEXcode V5 with Open Examples highlighted

There are four example projects: Left Arcade, Right Arcade, Split Arcade, and Tank Control. Image of the example project menu with the aforementioned projects highlighted

Discuss how the loops within the programs work, as well as the pros and cons of each type of control.

To relate this activity to math, use the left/right arcade (one joystick) and split arcade/tank drive (both joysticks) projects above to discuss the roles of the X and Y axes within the project.