Teacher training for sensor programming

Hello, Is there any teacher training materials available somewhere for programming various sensors through robot C? We recently got the advanced sensor kits for the 6 robots I have students working with. They are currently building the squarebot as that uses many more of the parts in the current kit then the swervebot does. I want to teach them to utilize all of the sensors well so need to learn more about programming them myself before I have them start trying to dive into them.

I know about the Carnegie Mellon training but the $999 is a bit much for right now. Also have been going through the VEX Video Trainer site which has been somewhat helpful but a lot of the sensor programming stuff is not available free.

We recently purchased Robot Virtual Worlds, I was hoping that would have more tutorials included in it but for the sensor parts it just really gives challenges to complete and not any real instruction on how to complete these challenges unless I am missing something.

Thanks for any help

I would definitely not recommend paying for the training. If you know where to look (which you seem like you do since you’re posting here), there’s an abundance of free information.

Back to the point:
I attached 2 slides of a presentation I made a while back on the basics of sensors and RobotC. With some tinkering with RobotC and the sensors (and my brief overview), you’ll probably be able to figure out most of what you would need to know. Also, the sensors’ product pages often contain some useful information. For example, the optical shaft encoder’s page’s Programming Resources tab has RobotC sample code.

Feel free to post here or PM me if you need additional clarification/information on something.

Go to YouTube. Do a search for “Robot C Sensors”. More info than you can imagine.

Though I know you mention it as being too expensive, it seems the Carnegie Mellon Online course is probably the cheapest commercial option. I’d be happy to be told I’m wrong. The free online robotics course materials are of varying levels of detail, and none appear to use the VEX EDR platform or RobotC. Again, I’d be happy to be told I’m wrong.

You only have to stay a tiny bit ahead of them, and (of course) it doesn’t hurt interested, motivated students to know their teacher is learning too. So come back here and ask specific questions, including looking for sample code and explanations for how the sensors work. You’ll have to turn that into class materials if you want something formal to present. But you could always give back to the community by making it available to other educators in your situation.

I see the CM course listed as $499 at this link. http://education.rec.ri.cmu.edu/training-vex-online/ That was after a very brief search, so I could easily be looking at a different course than you found. But this course might help. Unfortunately, it’s a slow-roll class, one meeting per week unless you’re in the Summer Session.

RVW is great, but it doesn’t include much in the way of instruction about sensors. And, in my experience, the kids aren’t nearly as impressed with moving something that looks to them like a bad video game with inefficient controls. Some of them will get excited about it, but nothing matches the feeling they get when lines of code make real hardware move.

Looks like your school district spends around $20,000 per student. Mine spends half that. I understand much of that is simple geography; LI is more expensive than bourbon country. But we work to get donations from a few sponsors just like it seems you’ve done for your VEXIQ club. Also, there were some grant programs available to help get VEXIQ off the ground. Not that you need that; looks like you hosted a VEXIQ event recently, so you’ve got that down.

One resource could be teachers with VEX RC teams near you. It looks like there are at least two strong programs near you, at Jericho High School (team 9932) and Massapequa SD (team 9458) both are doing well; perhaps their sponsors would be willing to arrange a mentoring session between their high schoolers and your middle schoolers as part of their STEM community outreach.

But no matter what, come back here and ask for specific information and help. You’ll need to say what sensor you’re working with, and it will be best to start a different topic for each request. Overall, most sensors we have available aren’t difficult to use, and examples and explanations are available for everything VEX has to offer.

[edit: Just to be clear, I have no affilition with REC F, RobotC, VEX EDR, IFI, etc. I’m just a parent, mentor, and coach.]
[second edit: changed “CM” to “CM course”]

Forgot to add something. Here is the team list from a recent tournament in your area. You may see someone else you could approach:


Also, here’s the page for a VEX Competition happening near you this Saturday:


You can click on the “team list” tab to see if there are any teams you know that will be attending. If it’s possible for you to go, you should. Even volunteer if possible, but at least go and talk to coaches/teachers. That can be very helpful.

So I suggest just reading code to get an idea for how everything works. Programming is really a skill best learned through reading code and just trying to write your own code. ROBOTC has a lot of example programs you can find in file → open sample programs.

Once you know how to read a sensor

and you know to command a motor
motor[drive] =127;

and you have a basic understand of program flow it isn’t difficult for you to understand how to write something like


I made some videos a few summers ago for robotC 3.x. They are a bit slow, so actually might be best for a more patient viewer. robotC videos

Wow, thank you for all the responses. I have been doing IQ for several years now. This is the first year with EDR, I have a small class right now with 10 students and 6 robots (the education swept away bundle) Started IQ with an REC/Grumman grant as well as local Endowment fund grants, and now have about 32 IQ bots used in class and in club. The online Carnegie melon is $499 in person is $999. I am digging through all of the links you guys shared with me.

Last year was my first year using robot C and with my IQ club and in class I have just done basic movement programming and with bump switches. I also understand basic movement programming, limit switches, bump switches, etc. I may just be over thinking things with these new sensors thinking that They are going to be much more difficult to program that I thought. I feel that I was also thinking that RVW was going to be more instructional than it seems to be. Another local teacher near me got RVW and was raving about how well he liked it which Is why I got my district to buy into it. My intention with it is to have the students test programs in RVW and on their real robot to compare differences in theoretical programming vs. real world (friction, traction, bent parts, etc. causing errors). I am not having students work only in RVW as I would have no interest in that even more than the kids!

It seems to me like the Robot designs used in RVW with build instructions that I can find are really written mainly off of the older EDR kits and not the current ones as some parts are not the same. Also the instructions for wiring do not match that of the way the robot is wired in the RVW motor/sensor setup. I had my students build as close the the “squarebot” as we possibly could with what we have so we are trying to programming in RVW and real world on the “squarebot”.

Right now I am having students try the “Basketball challenge” from RVW. I have them program it with basic movements Commands “Forward” “Backward” and then want them to right a program to complete it using the shaft encoders. My problem is I cannot figure out how to have the encoder record a backward movement.

So this code below is the sample shaft encoder move forward code. In order to have it then move backward the same distance what do I need to do? I tried copying the code over and changing the sensor value to -1800 with the speeds and -63 and the robot runs the distance forward than goes continuously backward. I tried changing it to the right encoder thinking its on the other side of the robot so spinning the opposite direction but that made no change to the robot.

Also wouldn’t I ideally want it reading both the right and left encoder to be sure that both side of the robot are moving equal distance to be sure the robot is actually going straight?

"task main()

//Clear Encoders
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 1800) // While less than 5 rotations on the leftEncoder…
//…Move Forward
motor[rightMotor] = 63;
motor[leftMotor] = 63;


Final question that I think will also help clarify some things for me, what is really the difference between Robot C coding with just “Vex 2.0 cortex” or “Natural Language 2.0 or PLTW” selected. I know PLTW is project lead the way and should align with their curriculum but what is really changing between the different ones? Just the preloaded functions? So for this year we have been working with “Natural Language 2.0” checked which I think is how it automatically comes. Is this that best one to work in or should I really be teaching something different?

Again thank you for all the help!


What you need is:

while(SensorValue[leftEncoder] > -1800)
  motor[rightMotor] = -63;
  motor[leftMotor] = -63;

However, there is a fundamental issue with the structure of your program. The driver control task should always end with an infinite loop (

while(1){ ... }

). Therefore, your encoder logic should use


rather than



I have been working with another teacher on a similar task. Maybe @DRow can make an educator channel. :slight_smile:

The following code is for a physical robot but I would suspect that it can be transposed for RVW.

Here is a link to that thread.

I modified the code to handle direction.

#pragma config(Sensor, dgtl1,  touch1,         sensorTouch)
#pragma config(Sensor, dgtl2,  encoderLeft,    sensorQuadEncoder)
#pragma config(Sensor, dgtl4,  encoderRight,   sensorQuadEncoder)
#pragma config(Motor,  port1,           left,          tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port10,          right,         tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Forward with Encoder function
//Parameters: p for power, ticks for encoder
void driveWithEncoder(int p, long ticks) {
	// Set encoders to 0
	SensorValue[encoderRight] = 0;
	SensorValue[encoderLeft] = 0;
	int direction = 1;
	//while absolute value of encoder is less than the absolute value of the destination (ticks)
	while (abs(SensorValue[encoderLeft]) < abs(ticks) && abs(SensorValue[encoderRight]) < abs(ticks))
		//check the direction of the destination. If less than 0 then backward.
		if(ticks < 0) 
			direction = -1;  
		} else
			direction = 1;
		//run the motors
		motor[left]  =  p * direction;
		motor[right] = -p * direction;  //motor inverted so turn the opposite direction
	// end while

	// Turn off the motors
	motor[right] = 0;
	motor[left]  = 0;

//end forwardWithEncoder
task main()
    // One rotation is 360 ticks. So three rotations would be 360 * 3 or about 38"	
		//Wait until bump button or 8 Up on joystick is pressed to move forward.
		if(SensorValue[touch1] || getJoystickValue(Btn8U)){
			// move forward at speed 60 for 3 rotations
			driveWithEncoder(60, 360 * 3);
		//Wait until 8 Down on joystick is pressed to move backward.
		if(getJoystickValue(Btn8D)) {
			//move backward at speed 60 for -3 rotations
			driveWithEncoder(60, 360 * -3);


I am not trying to run driver control at the end though. Just complete the basketball challenge. (http://www.nsd.org/site/handlers/filedownload.ashx?moduleinstanceid=63110&dataid=50555&FileName=basketball_drills.pdf

I can program it fine with just Forward, backward, now trying to have the encoder count the distances forward backward instead of using seconds.

Hey Doug, Went through a few of your videos and will continue to go through the rest, they are very helpful, thank you! I was wondering if you still had the tutorial robot C file you were going through in the video and could share that with me so I could read through everything with your comments and all? You show exactly what I am trying to do just have not gone over variables yet so am curious if I can figure out how to do it without. I know the code would end up a lot busier without setting the functions in the beginning but I haven’t really done anything with setting variables yet and see how useful learning that will be as well.