Creating a Project to Turn Left and Right in VEXcode Pro V5

The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.

VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.

This example program shows how to program the V5 Clawbot to turn left and right using VEXcode Pro Text.

#include "vex.h"

using namespace vex;

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Turn 90 degrees to the left.
  Drivetrain.turnFor(-90,degrees);

  // Wait for 1 seconds.
  wait(1, seconds);

  // Turn 180 degrees to the right.
  Drivetrain.turnFor(180, degrees);
}
How it works

This program used the turnFor(degrees, units) instruction to turn the robot for a specified degree. Degrees can be specified by using a numeric value.

You can specify the units by using degrees. A positive numeric value can be used to turn the robot to the left and a positive number value to move it to the right.

Steps executed in the program:

  1. The Drivetrain is set to turn 90 degrees to the left.
  2. The program will wait 1 second before executing the next line of code.
  3. The Drivetrain is set to turn the robot in the opposite direction which is 180 degrees to the right.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: