VCS Example Program with Controller - Modkit - Arcade Control

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 Text by following this article.

This example program shows how to use remote control values to move the robot.

ArcadeControl.vex

Configuration
  • A V5 Smart Motor, on Port 1, named leftMotor
  • A V5 Smart Motor, on Port 10, named rightMotor
Program

How it works

First, the  when (STARTED) block  tells the robot to run this code when the program starts.

Next, the program will enter a  while loop, which causes the program to run forever.

Then, the leftMotor and rightMotor velocities are set using the data from the joystick's  Axis values to calculate the velocity.

Because only one joystick is used to move the robot in Arcade mode, it is necessary to calculate the final velocity for each motor independently. 

Axis3 corresponds to the y-coordinate value of the joystick. So whether you push the joystick all of the way up to +100 or all of the way down to -100, it spins both motors the same direction.

Axis4 corresponds to the x-coordinate value of the joystick, so it works differently. If you push the joystick all of the way right to +100, then the left motor should have a positive velocity and the right motor should have a negative velocity so that the robot turns to the right. If you push the joystick all of the way left to -100, then the left motor should have a negative velocity and the right motor should have a positive velocity so that the robot turns to the left. 

Then,  the   .spin commands tell each motor to move along with the velocity specified in the previous commands.