How to best learn RobotC

Hey everyone! So, I am making this thread basically looking for recommendations as to how to learn to program in RobotC. My school recently acquired new RobotC licences for the VEX IQ division and it turns out they also got ones for VEX VRC as well. Up to this moment, the whole club has been using EasyC V4 so I would like to see what’s the best way for me to transition from EasyC V4 to RobotC. Any suggestions?

Having experience with both EasyC and RobotC, I can say that RobotC is my preferred program. I started with RobotC and then worked in EasyC, so my experience is in going the other way, but I think the transition will be much the same. I would start by using the functions library on the left side of the screen and seeing what functions are comparable (e.g. EasyC uses SetMotor(a,b) and RobotC uses motor[a]=b). After you use them a couple of times it will be pretty easy to make the switch.

Use the tutorials .

The sample programs that come with Robot C is a good place to start. getting used to the debugger helps as well. In the off season I would try a few things and try and recreate your autonomous and driver control from Easy C over to Robot C.

You then want to play with tasks and control loops. Look at the @jpearman programming thread for cool things like slew rate, task usage, and PID and/or TBH. Then try automating a few tasks on the buttons to make it easier to control.

So I tried doing what you all suggested and I have been able to get to know the program better. I’m still having a bit of trouble finding some functions but I found one of their help pages (which has helped greatly).

I tried moving my program from EasyC to RobotC manually in order to try it out and I was confused as to how to write the JoystickDigitalToMotorAndLimit function to RobotC, as this function does not exist. Any tips here?

Here’s what I did:

if (SensorValue(dgtl5) == 0)

In ROBOTC joystick control is done using the vexRT] command. In the brackets you put the corresponding joystick button name, like Btn5D or Ch3.

So for tank controls you might say:

motor[leftDriveTrain] = vexRT[Ch3]; //Ch3 is the left y-axis on the joystick
motor[rightDriveTrain] = vexRT[Ch2]; //Ch2 is the right y-axis on the joystick

Or to have a button activate a motor, you could do:

if (vexRT[Btn5U] == 1) { //when Btn5U is pressed on the joystick
  motor[intake] = 127; //set the intake motor power to 127
} else if (vexRT[Btn5D] == 1) { //if Btn5U is NOT pressed, but Btn5D is pressed...
  motor[intake] = -127; //set the intake motor power to -127
} else { //if neither Btn5U nor Btn5D is pressed...
  motor[intake] = 0; //don't run the intake motor

When you do button code for joystick controls, make sure you combine the if statements (that is, make an if-else statement) for two buttons that control the same motor (like in the example above), so you aren’t setting the motor to 0 and 127 power at the same time (it will look like the motor is jittering because the statements conflict). Also, there are ways to simplify this code into a one-line statement, but this is simpler to understand if you’re just starting out with ROBOTC.

The SensorValue command is basically the same in ROBOTC as it is in EasyC. However, you need to use brackets ] instead of parentheses:


By the way, in ROBOTC you can give all your motors and sensors names to help make programming them easier. You can just use the Name field in Motors and Sensors Setup.

Also, the VEX Cortex Video Trainer (you have to enter your email to view it) is another great resource, along with the help files (press F1) in ROBOTC.

In the help viewer there is a section labelled “Command Library - VEX Cortex”.
If you get stuck with an example section of code or you see something but don’t know how the code works or what a function call does, it will most likely be in there

Also under the section “General C Programming” There is some useful stuff there to understand how the language works

And the “Getting Started” content too