Programming instructions
Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Potentiometers • 3
Potentiometers Sample Code
bIfiAutonomousMode = false; //Enable Radio Control mode
while(true
) //Loop forever
{
if(vexRT[Ch5] == 127) //If the top Ch5 button is pressed...
{
if(SensorValue[armPotentiometer] < 900) //If the Potentiometer
{ //has not reached its maximum point...
motor[port6] = 31; //turn the motor on forward.
}
else //If the Potentiometer has reached
{ //its maximum point...
motor[port6] = 0; //turn the motor off.
}
}
if(vexRT[Ch5] == -127) //If the bottom Ch5 button is pressed...
{
if(SensorValue[armPotentiometer] > 550) //If the Potentiometer
{ //has not reached its minimum point...
motor[port6] = -31; //turn the motor on in reverse.
}
else //If the Potentiometer has reached
{ //its minimum point..
motor[port6] = 0; //turn the motor off.
}
}
}
Limiting Arm Movement with the Potentiometer
This code allows the rotating arm of a robot to be remote controlled using the Ch5 rear
buttons on the Radio Control Transmitter. The Potentiometer is used to prevent the motor
from spinning once the arm has reached its minimum and maximum points.
Go to Reference Links