Programming instructions
ROBOTC
ROBOTC Programming - Competition Templates • 6
©
2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems
#pragma config(Sensor, in1, bumper, sensorTouch)
//*!!Code automatically generated
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include “Vex_Competition_Includes.c”
void forwardUntilTouch()
{
while(SensorValue[bumper] == 0)
{
motor[port2] = 63;
motor[port3] = 63;
}
motor[port2] = 0;
motor[port3] = 0;
}
void pre_autonomous()
{
bMotorReflected[port2] = true;
}
task autonomous()
{
forwardUntilTouch();
motor[port6] = 31;
wait1Msec(250);
motor[port6] = 0;
}
task usercontrol()
{
while(true)
{
motor[port2] = vexRT[Ch2];
motor[port3] = vexRT[Ch3];
motor[port6] = vexRT[Ch6]/4;
}
}
Sample Competition Template with User Code
MotorsandSensorsconguredusing
theROBOTCMotors and Sensors
setupwindowwillautomaticallybe
addedaspragmastatementsatthe
topoftheprogram.
Whileit’snottechnicallyrequired,
it’sgoodprogrammingpracticeto
placeuser-denedfunctionsand/or
globalvariablesbelowthepragma
andincludestatements,andabovethe
template-includedfunctionsandtasks.
ThissetsthemotorconnectedtoVEX
Port2tospininreverse.
Commandsintheautonomousperiod
areexecutedonce(assumingthereareno
loopsinthecode).Also,noticethatthe
AutonomousCodePlaceholder-
ForTestingfunctionhasbeenremoved.
Commandsinthewhile(true)
loopoftheusercontrolperiod
areexecuteduntiltheendof
thematch.Also,noticethatthe
UserControlCodePlaceholder-
ForTestingfunctionhasbeen
removedfromtheloop.
ROBOTC Programming Competition Templates (cont.)
VEX ROBOTICS COMPETITION