Skip to main content
Teacher Portal

Controllers and Loops

VEXcode IQ example project. Beneath the When started block are 4 blocks to Set the Arm motor stopping to hold, set the Claw Motor stopping to hold, set the Arm motor velocity to 60% and the claw motor velocity to 30%. Next is a Forever block with 4 motion blocks inside. In order, they read set left motor velocity to Controller A position %, Set right motor velocity to Controller D position %, spin left motor forward, spin right motor forward.
Clawbot Control example project from VEXcode IQ

Controllers and Loops

In competitions, teams use controllers to wirelessly control their robots. 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 image above shows the Clawbot Control example project from VEXcode IQ. The forever loop in this project checks the positions of Axes A and D forever in order to set the velocity of the motors.

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

Motivate Discussion icon Motivate Discussion - Looping Behaviors

Review this year's VEX IQ Competition game with students by clicking on this link. Or, have the following discussion based around previous years' games.

Q: Which behaviors are likely to be repeated by the robot during a competition?
A: Students will likely immediately respond with movements but the project is less likely to use loops for movements than it is to use loops for checking sensors.

Q: How would you make these repetitive behaviors into a loop?
A: No matter the behavior(s) being repeated, dragging the blocks inside of a loop is a required step. Students need to be comfortable nesting blocks inside of loop blocks.

Q: Ask students which block in VEXcode IQ could help them program their robots to behave after a single controller button is pressed. Also, ask which group of blocks it is part of.
A: That block is called the When controller button block and it is located under the Events blocks in VEXcode IQ.

Extend Your Learning icon Extend Your Learning - Reviewing Example Projects

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 IQ. There are four example projects: Left Arcade, Right Arcade, Split Arcade, and Tank Drive.

VEXcode IQ Toolbar with the File menu open, and Open Examples selected with a red box. 'Open Examples' is the fourth item in the menu.

Example project selection window with the following project icons highlighted with red boxes: Left Arcade, Right Arcade, Split Arcade, and Tank Drive.

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. Readings of the X axis position capture left-right, horizontal movements of the joystick(s) whereas readings from the Y axis position capture up-down, vertical movements of the joystick(s).