#pragma config(Motor, port2, frontRightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port9, frontLeftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port2, backRightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port9, backLeftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port3, clawMotor, tmotorNormal, openLoop)
#pragma config(Motor, port8, frontLeftArmMotor, tmotorNormal, openLoop)
#pragma config(Motor, port4, frontRightArmMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port6, backRightArmMotor, tmotorNormal, openLoop, reversed)
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as “competition”
#pragma competitionControl(Competition)
//Main competition background code…do not modify!
#include “Vex_Competition_Includes.c”
/----------------------------------------------------------------------------------------------------
|* - Robot 98225K Single Controller - |
| ROBOTC on VEX 2.0 Cortex |
| |
| This program uses joystick,for right and left drive on the robot. The buttons on the back right of*|
|* the controller are used to raise and lower the arm. The buttons on the front right of |
| the controllerare used to open and close the claw. |
| ROBOT CONFIGURATION |
| NOTES: |
| 1) Running through a y-cable on each side, both motors are connected and flowing into one port.|
| 2) Buttons 8U and 8D on the front right side of the joystick to open and close the claw |
| 3) Buttons 6U and 6D are on the back right of the joystick to move arm up and down. |
| |
| MOTORS & SENSORS: |
| * [Name] [Type] [Description] |
| Motor - Port 2 frontRightMotor Y-Cable Right side motor |
| Motor - Port 2 backRightMotor Y-Cable Right side motor |
| Motor - Port 9 frontLeftMotor Y-Cable Left side motor |
| Motor - Port 9 backLeftMotor Y-Cable Left side motor |
| Motor - Port 3 clawMotor VEX 393 Motor w/ Motor Controler 29 Claw motor |
| Motor - Port 5 armMotor3 VEX 393 Motor w/ Motor Controler 29 Arm motor3 |
| Motor - Port 6 armMotor2 VEX 393 Motor w/ Motor Controler 29 Arm motor2 |
| Motor - Port 7 armMotor1 VEX 393 Motor w/ Motor Controler 29 Arm motor1 |
*----------------------------------------------------------------------------------------------------/
//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
void pre_auton()
{
bStopTasksBetweenModes = true;
}
task autonomous()
{
AutonomousCodePlaceholderForTesting();
}
task usercontrol()
{
while(1 == 1)
{
//Right side of the robot is controlled by the right joystick, Y-axis
motor[backRightMotor] = vexRT[Ch2];
//Left side of the robot is controlled by the left joystick, Y-axis
motor[backLeftMotor] = vexRT[Ch3];
}
// Raise, lower or do not move arm
{
if(vexRT[Btn5U] == 1) //If button 5U is pressed…
{
motor[frontRightArmMotor] = 100; //…raise the arm.
motor[frontLeftArmMotor] = 100; //…raise the arm.
}
else if(vexRT[Btn5D] == 1) //Else, if button 5D is pressed…
{
motor[frontRightArmMotor] = -100; //…lower the arm.
motor[frontLeftArmMotor] = -100; //…lower the arm.
}
else //Else (neither button is pressed)…
{
motor[frontRightArmMotor] = 0; //…stop the arm.
motor[frontLeftArmMotor] = 0; //…stop the arm.
}
// Raise, lower or do not move upper arm
{
if(vexRT[Btn7U] == 1) //If button 7U is pressed…
{
motor[backRightArmMotor] = 100; //…raise the upper arm.
}
else if(vexRT[Btn7D] == 1) //Else, if button 7D is pressed…
{
motor[backRightArmMotor] = -100; //…lower the upper arm.
}
else //Else (neither button is pressed)…
{
motor[backRightArmMotor] = 0; //…stop the upper arm.
}
// Open, close or do not more claw
if(vexRT[Btn6U] == 1) //If Button 6U is pressed…
{
motor[clawMotor] = 95; //…close the gripper.
}
else if(vexRT[Btn6D] == 1) //Else, if button 6D is pressed…
{
motor[clawMotor] = -95; //…open the gripper.
}
else //Else (neither button is pressed)…
{
motor[clawMotor] = 0; //…stop the gripper.
}
}
}
}
Why will this code not work? The driving works but none of the arm motors or claw motors will move, and all the wires are connected. What could be wrong?
*