Help me go from "no knows" to "knows PROS"

I would like your help to learn PROS from a beginner’s perspective. I don’t have much programming experience at all, just a very little experience with EasyC.

I have watched Cody’s PROS Beginner Series. (It was excellent, thank you!)

I also find jpearman’s post with example code very helpful.

Of course there is the PROS tutorial. It may be a little beyond me. The C basics tutorial doesn’t seem to answer my VEX specific questions.

A little more background…
We are starting up a new robotics program at the local school. We finished a late unofficial league just after the VEX Worlds competition.

The students programmed their robots using EasyC on laptops borrowed from a neighboring school district’s robotics program. We kept a robot together for demonstrations when recruiting additional students this coming fall.

I don’t want to download bits of test code yet, I would like to have a workable PROS program for user control before I download anything onto the cortex.

The very first basic issue, help me run a motor in operator control using PROS.

//QUESTION 1: what does the void do? I see it used a lot. I'm sure Cody
//covered this. It just says that there is no initial value, correct?
void operatorControl() {
    while (1) {
        // Motor port 1 is set to the analog value of Joystick 1, Axis 3?
        motorSet( 1,  joystickGetAnalog( 1, 3 ));

        // Don't hog cpu. Wait 20ms before rerunning this loop?

Does this all look ok?

Google is your friend.
void - wikipedia

void simply means “no type”, so the the operatorControl function does not return anything (and in general should not return at all).

That code looks ok.

Why go with PROS and not ROBOTC?

Thank you.
At this time we don’t have a budget to purchase programming seats. I’m trying to learn a little something before fall comes so I can pass on a little knowledge to other coaches/mentors and students.

At some point we’ll be purchasing seats for EasyC or RobotC for VEX EDR and VEX IQ teams from 5 elementary schools, a junior high, and a high school. The district that is helping us get things started uses EasyC. We will have to decide what we want to use. It sounds like any PROS experience I pick up should transfer over to the other programs.

I want to create a function for driving forward

void forward() {
        motorSet( 2,  joystickGetAnalog( 1, 3 ));
        motorSet( 3,  joystickGetAnalog( 1, 3 ));
        //How do I invert the power values for these two motors?
        motorSet( 4,  joystickGetAnalog( 1, 3 ));
        motorSet( 5,  joystickGetAnalog( 1, 3 ));

Where do I place this code? Do I right-click on opcontrol and Create a new File? File from template?

I need to “initialize” the function in the operator control file, correct?

You define/create a function in a source file, it could be in the same file as opcontrol. You call a function when you need to use it.

Get a copy of this, it’s the C bible.
The C Programming Language

I should really read more.

THANK YOU! God I was wondering if that was worth the effort.

Those kind of tutorials take A LOT of effort to produce. That took me like days.

I really want to do an overview of the API and actually code for the Cortex. I should do that… Maybe when my voice returns (stupid stupid cold won’t die).

Functions go in .c files, there is scope to deal with, a function must be written ABOVE code that calls it in the same file to be in scope, or included (also above). You can create a definition (kind of like an index) of a function if you want to declare it under, or later in a file.

I HIGHLY RECOMMEND THIS TUTORIAL. It might help you fill in the gaps.

I feel like just a few real code examples would set everything straight for me.

I helped the students use EasyC to program a robot with a 4-bar lift. With that and other info sources I have a (very) basic understanding of these concepts. We even used EasyC to program an [IF]/[ELSE] [IF]/[ELSE] statement to lift/lower/hold the 4-bar linkage. Your tutorial showed a better way (more than 1 actually). (Using SWITCH I think, I’m excited to try it). I just need the syntax of how to drive the motors, and where to put functions you might use in multiple programs.

I remember the order requirements from your tutorial. I could easily re-watch your tutorials and glean a lot more info.

Which we call a function prototype (and I know you know that Cody). Using function prototypes is a good habit to get into.

Worth the effort? You are a rock star here with the omni drive posts, this post and all the tutorials. If I look at my link list you are only slightly behind James on the “Ok, so how does this work list?”

Open source is crap. Open Source with a readme is junk.

Open source with tutorials are software gold. Thanks for your work!

I tell my roboteers, if you can’t explain it, it’s worthless.


When I get back tonight I will whip up some small sample code with a structure like that we use in competition to look at. I will be sure to comment it thoroughly to help in understanding. I know that our documentation could use some additions and that is one of our todo’s for this summer.

Yeah you got me… I’d like to blame the cold but I think that was just one of my stupid moments.

Thanks Foster!!!

That would be great.

Just going to drop this here. I’ll make a thread about it when I consider it finished. Video #2 is encoding now.

Should get you going.

Cody thanks for those great tutorials! I have fallen asleep watching and listening. I also have the 2nd edition C Programming book… it is straight forward and very useful. I think in my case learning PROS is my long term goal, but RobotC is more reasonable on the learning curve. I think that learning RobotC and the process first will help me on PROS. Right now I have 1 team going to TSA VEX Nationals and 2 other teams already working on NbN. So… the main programmer for the A team wants to learn coding after TSA VEX. Hopefully he can transition to it fast from EasyC.
Again… Thanks Cody!

Bill R.

I noticed that no one posted any code for you yet, here is an example.

Arcade drive for four motors and a one motor lift. The code is slightly more complicated than necessary but it demonstrates several important habits you should learn.

Use of functions to simplify the code.
Use of variables
defining important numbers (in this case the motor channels) away from the body of the code.

#include "main.h"

// My motor channels
#define     MotorLF     2
#define     MotorLB     3

#define     MotorLift   5

#define     MotorRF     8
#define     MotorRB     9

/*  Simple one motor lift control on button 8 up and down                      */

    int  drive_lift;
    int  vex_Btn8U = joystickGetDigital( 1, 8, JOY_UP );
    int  vex_Btn8D = joystickGetDigital( 1, 8, JOY_DOWN );

    // get control value
    if( vex_Btn8U )
        drive_lift = 127;
    if( vex_Btn8D )
        drive_lift = -127;
        drive_lift = 0;

    // set the motor
    motorSet( MotorLift, drive_lift );

/*  Simple arcade drive using joystick Ch3 and Ch4                             */

    int  forward, turn;
    long drive_l;
    long drive_r;

    // Get the joystick values
    int  vex_ch3 = joystickGetAnalog( 1, 3 );
    int  vex_ch4 = joystickGetAnalog( 1, 4 );

    // create forward and turn variables
    // use a deadband of 10
    if( abs( vex_ch3 ) > 10 )
        forward = vex_ch3;
        forward = 0;

    if( abs( vex_ch4 ) > 10 )
        turn = vex_ch4;
        turn = 0;

    // Set drive
    drive_l = forward + turn;
    drive_r = forward - turn;

    // normalize drive so max is 127 if any drive is over 127
    int max = abs(drive_l);
    if (abs(drive_r)  > max)
        max = abs(drive_r);
    if (max>127) {
        drive_l = 127 * drive_l / max;
        drive_r = 127 * drive_r  / max;

    // Send to motors
    // left drive
    motorSet( MotorLF, drive_l);
    motorSet( MotorLB, drive_l);

    // right drive
    motorSet( MotorRF, drive_r);
    motorSet( MotorRB, drive_r);

/*  operator control function                                                  */

void operatorControl() {

    while (1) {
        // arcade drive

        // Simple one motor lift

        // Don't hog cpu

Adam - I do apologize about getting back late. Relocating for the summer has taken more out of me then I had anticipated. I have included a link below to a zip of the project that I created as an example. After you download it unzip the project and import it into PROSe. To import, right click in the project explorer select -> import -> existing projects into workspace -> browse to the folder -> click finish.

Upon completion of this look at the bottom panel in PROSe and select the task tab. Follow the TODOs in order and fill in the information needed for your specific set up.

I hope that the logic flow is clear and if you have any questions please feel free to ask.