Hi. This is my first year using RobotC and I’ve had a few issues when it comes to actually running the program on my robot. I think it might be because I need a competition switch for the program I have written, but that might not be it. Anyway, after I have downloaded the program and attempt to drive the robot, there is no response from any of the motors. Any suggestions?
Here is the code (Sorry for the length):
#pragma config(Motor, port1, driveLF, tmotorVex393, openLoop)
#pragma config(Motor, port2, driveRF, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port3, driveLR, tmotorVex393, openLoop)
#pragma config(Motor, port4, driveRR, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port5, liftLT, tmotorVex393, openLoop)
#pragma config(Motor, port6, liftLB, tmotorVex393, openLoop)
#pragma config(Motor, port7, liftRT, tmotorVex393, openLoop)
#pragma config(Motor, port8, liftRB, tmotorVex393, openLoop)
#pragma config(Motor, port9, intakeL, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, intakeR, tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
//create a function that runs drive motors forward for a sepcified time at a specified speed
void autoDrive(int speed, int time)
{
motor[port1] = speed; //run motors at speed
motor[port2] = -speed;
motor[port3] = speed;
motor[port4] = -speed;
wait1Msec(time);
}
////////////////////////////LCD FUNCTIONS////////////////////////
//Wait for Press--------------------------------------------------
const short leftButton = 1;
const short centerButton = 2;
const short rightButton = 4;
void waitForPress()
{
while(nLCDButtons == 0){}
wait1Msec(5);
}
//----------------------------------------------------------------
//Wait for Release------------------------------------------------
void waitForRelease()
{
while(nLCDButtons != 0){}
wait1Msec(5);
}
//PRE - AUTONOMOUS/////////////////
void pre_auton()
{
//Declare count variable to keep track of our choice
int count = 0;
//------------- Beginning of User Interface Code ---------------
//Clear LCD
clearLCDLine(0);
clearLCDLine(1);
//Loop while center button is not pressed
while(nLCDButtons != centerButton)
{
//Switch case that allows the user to choose from 4 different options
switch(count){
case 0:
//Display first choice
displayLCDCenteredString(0, "Blue Skyrise");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count = 3;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 1:
//Display second choice
displayLCDCenteredString(0, "Blue NonSkyrise");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 2:
//Display third choice
displayLCDCenteredString(0, "Red Skyrise");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 3:
//Display fourth choice
displayLCDCenteredString(0, "Red NonSkyrise");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count = 0;
}
break;
default:
count = 0;
break;
}
}
}
//Autonomous////
task autonomous()
{
int count = 0;
//------------- Beginning of Robot Movement Code ---------------
//Clear LCD
clearLCDLine(0);
clearLCDLine(1);
//Switch Case that actually runs the user choice
switch(count){
case 0:
//If count = 0, run the code correspoinding with choice 1
displayLCDCenteredString(0, "Blue Skyrise");
displayLCDCenteredString(1, "is running!");
// Move forward at full power for 3 seconds
break;
case 1:
//If count = 1, run the code correspoinding with choice 2
displayLCDCenteredString(0, "Blue NonSkyrise");
displayLCDCenteredString(1, "is running!");
// Move reverse at full power for 3 seconds
break;
case 2:
//If count = 2, run the code correspoinding with choice 3
displayLCDCenteredString(0, "Red Skyrise");
displayLCDCenteredString(1, "is running!");
//Turn right for 3 seconds
break;
case 3:
//If count = 3, run the code correspoinding with choice 4
displayLCDCenteredString(0, "Red NonSkyrise");
displayLCDCenteredString(1, "is running!");
//Turn left for 3 seconds
break;
default:
displayLCDCenteredString(0, "No valid choice");
displayLCDCenteredString(1, "was made!");
break;
}
}
//USER CONTROL////////////////////
task usercontrol()
{
while (1==1)
{
//holonomic drive with forward/reverse motion on channel 3, strafing on channel 1, and rotation on channel 1
motor[port1] = vexRT[Ch3] - vexRT[Ch4] - vexRT[Ch1];
motor[port2] = vexRT[Ch3] + vexRT[Ch4] + vexRT[Ch1];
motor[port3] = vexRT[Ch3] - vexRT[Ch4] + vexRT[Ch1];
motor[port4] = vexRT[Ch3] + vexRT[Ch4] - vexRT[Ch1];
//lift: up is 5U, down is 5D
if (vexRT[Btn5U] == 1)
{
motor[port5] = 127;
motor[port6] = 127;
motor[port7] = -127;
motor[port8] = -127;
}
else if (vexRT[Btn5D] == 1)
{
motor[port5] = -80;
motor[port6] = -80;
motor[port7] = 80;
motor[port8] = 80;
}
else
{
motor[port5] = -20;
motor[port6] = -20;
motor[port7] = 20;
motor[port8] = 20;
}
//intake: out is 6U, in is 6D
if (vexRT[Btn6U] == 1)
{
motor[port9] = 127;
motor[port10] = 127;
}
else if (vexRT[Btn6D] == 1)
{
motor[port9] = -127;
motor[port10] = -127;
}
}
}
Thanks in advance!