Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Reserved Words 3
Reserved Words
ClearTimer(T1); //Clear Timer #1
ClearTimer(timer);
This resets the referenced timer back to zero seconds.
The VEX has 4 internal timers: T1, T2, T3, and T4
if(SensorValue(in1) == 1) //If in1 (bumper) is pressed
{
motor[port3] = 127; //Motor Port 3 full speed forward
}
SensorValue(sensor_input)
SensorValue is used to reference the integer value of the specied sensor port.
Values will correspond to the type of sensor set for that port.
The VEX has 16 analog/digital inputs: in1, in2... to in16
PlayTone(220, 500); //Plays a 220hz tone for 1/2 second
Sounds
The VEX can play sounds and tones using an external piezoelectric speaker attached to a motor
port.
PlayTone(frequency, duration);
This plays a sound from the VEX internal speaker at a specic frequency (1 = 1 hertz) for
a specic length (1 = 1/100th of a second).
Type of Sensor Digital/Analog? Range of Values
Touch Digital 0 or 1
Reection (Ambient) Analog 0 to 1023
Rotation (Older
Encoder)
Digital 0 to 32676
Potentiometer Analog 0 to 1023
Line Follower (Infrared) Analog 0 to 1023
Sonar Digital -2, -1, and 1 to 253
Quadrature Encoder Digital -32678 to 32768
Digital In Digital 0 or 1
Go to Reference Links