Left and Right - Modkit

Get more with VEXcode
We recommend you transition to our new software. VEXcode has both block-based and text-based options, that work on Chromebooks, iPads, Android tablets, Windows and Macs. Visit code.vex.com for more details on how to download VEXcode.
VEX Coding studio has been discontinued and is no longer available for download. Already downloaded? The program will continue to function but will no longer be supported.
Users who transition to VEXcode can migrate their C++/C++ Pro projects to VEXcode Pro V5 by following this article.

This example program shows how to program the V5 Clawbot to turn left and right using Modkit.


  • A V5 Smart Motor, on Port 1, named LeftMotor.
  • A V5 Smart Motor, on Port 10, named RightMotor and set to Reversed.


How it works

First, the when (STARTED) block tells the robot to run this code when the program starts. A number variable, revsPerClawbot90Turn is declared and assigned to 1.7.

This value should turn a V5 Clawbot with 18:1 gear motors approximately 90 degrees. Based on the weight of the robot and the friction of the wheels, the amount of turn may be slightly more or less than 90 degrees. You can adjust  the  revsPerClawbot90Turn  variable if desired.

Then, the left motor is set to start rotating with a negative number of revolutions. Since startRotateFor is used the motor will begin rotating and the program will continue immediately.

Next, the right motor is set to rotate, but with a positive number of revolutions. Since rotateFor is used the program will not continue until the motor completes its rotation.

Since the motors are set to rotate in opposite directions, with the left motor rotating backward, the robot will turn in place to the left. The facing of the V5 Clawbot will change by about 90 degrees.

Then, when the right motor has finished rotating, the program will pause for 1 second.

Finally, the motor rotation blocks are repeated. This time, the positive and negative rotations are switched and multiplied by 2. The motors will spin in the opposite direction and twice as far, which will turn the robot to face in the opposite direction.