Programming instructions

RO BOTC
Reference
Reserved Words 1
©
Carnegie Mellon Robotics Academy / For use with VEX
®
Robotics Systems
Reserved Words
motor[port3]= 127; //port3 - Full speed forward
motor[port2]= -127; //port2 - Full speed reverse
motor[port3]= 127; //port3 - Full speed forward
motor[port2]= 127; //port2 - Full speed reverse
bMotorReected[port2]= 1; //Flip port2’s direction
motor[port3]= 127; //port3 - Full speed forward
motor[port2]= 127; //motorA - Full speed forward
Motors
Motor control and some ne-tuning commands.
motor[output] = power;
This turns the referenced VEX motor output either on or off and simultaneously sets its power level.
The VEX has 8 motor outputs: port1, port2... up to port8. The VEX supports power
levels from -127 (full reverse) to 127 (full forward). A power level of 0 will cause the motors to stop.
bMotorReected[output] = 1; (or 0;)
When set equal to one, this code reverses the rotation of the referenced motor. Once set, the
referenced motor will be reversed for the entire program (or until bMotorReected[] is set equal to
zero).
This is useful when working with motors that are mounted in opposite directions, allowing the
programmer to use the same power level for each motor.
There are two settings: 0 is normal, and 1 is reverse. You can use “true” for 1 and “false” for 0.
Before:
After:
motor[port3]= 127; //port3 - full speed forward
wait1Msec(2000); //Wait 2 seconds
motor[port3]= 0; //port3 - off
Timing
The VEX allows you to use Wait commands to insert delays into your program. It also supports
Timers, which work like stopwatches; they count time, and can be reset when you want to start or
restart tracking time elapsed.
wait1Msec(wait_time);
This code will cause the robot to wait a specied number of milliseconds before executing the
next instruction in a program. “wait_time” is an integer value (where 1 = 1/1000th of a second).
Maximum wait_time is 32768, or 32.768 seconds.