, ,

VEX Robotics – Getting Started

Installing VEXCode Pro V5

This guide will show you how to download and install VEX Code Pro V5 on your computer.

Go to www.vexrobotics.com/vexcode-download

Download VEXcode Pro V5

Run the installer

Let any windows pop up install any drivers

You might need to manually close these windows

The installer will then finish

Run VEXcode Pro V5

You have now install VEXcode Pro

Version Control

It is recommended that you complete the Version Control – GitHub setup guide to help with managing your project.

Choosing where files are saved

Open VEXcode Pro V5

Open the File Menu and choose Preferences

Here you can choose key settings for ALL projects.

Click on directory names next to Program Folder

A Browse For Folder window will appear

Browse and choose a folder where you want to save your work

It is really important that you know where this folder is.

It is recommended that you have this folder as one that is linked to a version control repository like Github

Setting up the Program Files (Your First Program)

Using the competition template is a great way to get started writing code and programming your robot.

This gives you access to the autonomous and user controlled sections so that you can easily write code for the robot to carry out by itself and when controlled by a person using the controller.

Choose Open Examples

Select Competition Template

Give the Project a name

In C++ (and other C derived languages) variable, function and file names are written in CamelCase

These cannot start with a number of have spaces in them, underscore _ is ok.

You now have a skeleton program set up.

The pre_auton() section is used to set up the robot before anything moves or the autonomous code or user control code executes.

The autonomous function is where you write the code to carry out the tasks for the 15 second autonomous section.

The usercontrol function has a while loop inside it.

It is in this while loop where the code is written for when the user is entering inputs with the controller.

Each time the while loop executes (runs one iteration of the loop) each of the instructions inside the loop will be carried out.

Connecting the Robot and Brain

You need to connect the robot and the brain together.

You’ll need a:

  • V5 Brain
  • V5 Battery
  • V5 Battery Cable
  • Micro USB Cable

Connect the Brain and Battery using the cable

Plug the USB Cable into the Brain and then plug the other end of the USB Cable into the Computer

When the Brain (or other devices) is connected the icon will light up green

If there are updates that are needed to be carried out there will be a notification.

You can check if it’s up to date by clicking on the icon.

If you need to update other devices like the Controller connect them with a smart cable.

When the devices are connected and the Brain powered on the device will update.

You use smart cables to connect other devices like motors and the radio.

Writing a Program (Drawing on the Brain)

The V5 Brain is automatically added to any VEX Project.

To access the command reference click on the ? in the top right

Here you can see example pieces of code that can be used to carry out activities using the Brain

We are going to write a function that will print a message on the Brain.

This will be called (run) from the pre_auton(void) function.

Go to line 31 and add a couple of blank lines

Write the following:

This will create a function called displayName()

This function will not return a value when it finishes. We can tell this by the use of the void keyword. Void means empty in programming.

Inside the { } add code to carry out a task.

Add the code to draw a circle

It takes three arguments (parameters) its x and y position on the screen and the radius of the circle.

The coordinate 0,0 is in the top left. The x axis increases going right and the y axis increases going down

Position the circle at 100,150 with a radius of 75.

Note the ; at the end of the line

This tells the computer / compiler that this is the end of an instruction.

It’s like a full stop in English.

We have now written a function.

Now we need to call it from another function

In the pre_auton function add the line

displayName(); to call the function.

Replace displayName() with the name of your function

To compile (make/build) your program click the button in the top right that looks like a down arrow.

If there are no problems check the output message below for any problems.

They’ll often be highlighted in red

Click the Play button in VEXCode VR or the Run button on the V5 Brain to run the program.

Then you’ll see the output

Press and hold the stop button to close the running program.

Getting Help

The VEX Forum is a great place to gather ideas.

The VEX Knowledge Base has a lot of information as well.

In VEXCode click on the ? in the top right corner.

This will bring up the Command Reference.

The Command Reference has examples of code that can be included.

It is context sensitive and ass you add more devices to the program (motors, sensors) there will be additional examples included.

You might also like