#pragma config(Motor, port2, rightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port6, armMotor, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{

/*Anything after task main and before the while loop will run only once.
Anything inside the while loop will run continuously until what’s in the parenthesis is no longer true. In this case it will run forever (or until the robot is turned off) since 1 is always equal to 1.*/

while(1 == 1)
{

//This is tank drive
motor[leftMotor] = vexRT[Ch3]; /* Set the left motor power equal to the
left joystick vertical axis*/

motor[rightMotor] = vexRT[Ch2]; /* Set the right motor power equal to the
right joystick vertical axis*/

//Arm motor control
if(vexRT[Btn6U] == 1) //If the group 6 Up button is pressed...
{
motor[armMotor] = 40; //...then raise the arm.
}
else if(vexRT[Btn6D] == 1) //But if the group 6 down button is pressed...
{
motor[armMotor] = -40; //...then lower the arm.
}
else //But if no button is pressed...
{
motor[armMotor] = 0; //...stop the arm.
}

}

/*Anything after the while loop will only run once and only run if the while statement is false. In
this example, anything here would never run.*/

}

To turn on a motor

motor[name of motor] = number between -127 and 127

To read a value from the controller:

vexRT[name of channel]

·  Ch1 = right joystick horizontal

·  Ch2 = right joystick vertical

·  Ch3 = left joystick vertical

·  Ch4 = left joystick horizontal

·  Btn5U and Btn5D are the up and down buttons on the back left of the controller

·  Btn6U and Btn6D are the up and down buttons on the back right of the controller

·  Btn7L, Btn7R, Btn7U, Btn7D are the left, right, up and down buttons on the front right side of the controller.

·  Btn8L, Btn8R, Btn8U, Btn8D are the left, right, up and down buttons on the front left side of the controller.

·  There is also an x tilt and y tilt accelerometer (programmed as a sensor)

Notes:

·  To test to see if two things are equal, use ==

·  To make something be equal to something else use =

·  At the end of each line, there needs to be a semicolon ;

·  To comment out one line, use //

·  To comment out more than one line, use /* at the beginning and */ at the end.

·  The pragma statements at the top are automatically generated when you set up your motors and sensors using the “Motor and Sensor Setup” button above the code in RobotC.