Need help with my Robotc Program!!!

Okay, so today when we were working on our robot, it was functioning just fine when we turned on our remotes, they connected and every function worked as it has always. Then later I uploaded a revised version of my code, and now nothing works on my robot. The remotes connect perfectly, but nothing on either remote makes the robot work. I made sure everything was updated on the remotes and cortex, and there were up to date. All the lights were green on the remotes and the cortex, nothing unusual was happening. I did a hard wire connection from the remote to my robot to see if it had anything to do with the vex nets, and it still didn’t work. The only thing I changed in my program was adding some code to the pre-auton section about LCD display stuff and adding some stuff about integrated encoders in the autonomous section, but nothing in the user-control. So why is the user control not working? If anyone has any clue what is going on or how to fix it, please let me know. Thanks in advance.

Post the code.

All of it, including the pre-auton, autonomous, and user-control?

Here is my usercontrol program only…

task usercontrol()
{
while (true)
{
motor(wheel1) = vexRT[Ch2]; //wheel1 will move
motor(wheel2) = vexRT[Ch3]; //wheel2 will move
motor(wheel3) = vexRT[Ch3]; //wheel3 will move
motor(wheel4) = vexRT[Ch2]; //wheel4 will move
motor(firstarm) = vexRT[Ch3Xmtr2]; //first arm will rise/fall on remote #2
motor(secondarm) = vexRT[Ch2Xmtr2]; //second arm will rise/fall on remote #2

	if(vexRT[Btn6UXmtr2] == 1) //if button 6U is pressed on remote #2
	{
		motor(claw1) = -80; //claw will grab
		wait1Msec(1500);
		motor(rotateclaw) = 0;
	}
	else if(vexRT[Btn6DXmtr2] == 1)//if button 6D is pressed on remote #2
	{
		motor(claw1) = 80;//claw will release
		wait1Msec(1500);
		motor(rotateclaw) = 0;
	}
	if(vexRT[Btn5U] == 1)//if button 5U is pressed on remote #1
	{
		motor(rotateclaw) = 127;//servo will rotate to pick up skyrise
	}
	else if(vexRT[Btn5D] == 1)//if button 5D is pressed on remote #1
	{
		motor(rotateclaw) = 0;//servo will rotate to pick up cubes
	}
}

}

task autonomous()
{

//Auto Skyrsie Red

//--- Beginning of Robot Movement Code ---
int count = 0;
//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, "Auto Skyrsie Red");
	displayLCDCenteredString(1, "is running!");
	wait1Msec(2000);						// Robot waits for 2000 milliseconds

	nMotorEncoder[wheel1]=0;
	nMotorEncoder[wheel2]=0;
	nMotorEncoder[wheel3]=0;
	nMotorEncoder[wheel4]=0;

	motor[firstarm] = 126;//first arm will raise up a little
	motor[secondarm] = 126;//second arm will raise up a little
	motor[claw1] = -126;//claw will open
	wait1Msec(1000);//for 1 second

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn right
	motor[wheel3] = -126;//robot will turn right
	motor[wheel4] = -126;//robot will turn right
	wait1Msec(2000);//for 2 seconds

	motor[firstarm] = -126;//first arm will lower down
	wait1Msec(400);//for 0.4 seconds

	motor[claw1] = 126;//claw will close
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will raise
	wait1Msec(400);//for 0.4 seconds

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn left
	motor[wheel3] = 126;//robot will turn left
	motor[wheel4] = 126;//robot will turn left
	wait1Msec(2500);//for 2.5 seconds

	motor[firstarm] = -126;//first arm will lower a little
	motor[secondarm] = -126;//second arm will lower a little
	wait1Msec(900);//for 0.9 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second
	//9200 Msecs long, 5800 seconds left
	break;
case 1:
	//If count = 1, run the code correspoinding with choice 2
	displayLCDCenteredString(0, "Auto Skyrsie Blue");
	displayLCDCenteredString(1, "is running!");
	wait1Msec(2000);						// Robot waits for 2000 milliseconds

	////////////////////////////////////////////////////////////////////////////////////////////////////Auto Skyrsie Blue

	motor[firstarm] = 126;//first arm will raise up a little
	motor[secondarm] = 126;//second arm will raise up a little
	motor[claw1] = -126;//claw will open
	wait1Msec(1000);//for 1 second

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn left
	motor[wheel3] = 126;//robot will turn left
	motor[wheel4] = 126;//robot will turn left
	wait1Msec(2000);//for 2 seconds

	motor[firstarm] = -126;//first arm will lower down
	wait1Msec(400);//for 0.4 seconds

	motor[claw1] = 126;//claw will close
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will raise
	wait1Msec(400);//for 0.4 seconds

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn right
	motor[wheel3] = -126;//robot will turn right
	motor[wheel4] = -126;//robot will turn right
	wait1Msec(2500);//for 2.5 seconds

	motor[firstarm] = -126;//first arm will lower a little
	motor[secondarm] = -126;//second arm will lower a little
	wait1Msec(900);//for 0.9 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second
	//9200 Msec long, 5800 seconds left

	break;
case 2:
	//If count = 1, run the code correspoinding with choice 2
	displayLCDCenteredString(0, "Auto Cubes red-driver, blue-X");
	displayLCDCenteredString(1, "is running!");
	wait1Msec(2000);						// Robot waits for 2000 milliseconds


	///////////////////////////////////////////////////////////////////////////////////////////////////Auto Cubes red-driver, blue-X

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn left
	motor[wheel3] = 126;//robot will turn left
	motor[wheel4] = 126;//robot will turn left
	wait1Msec(600);//for 0.6 seconds

	motor[firstarm] = 126;//first arm will raise up
	motor[secondarm] = 126;//second arm will raise up
	motor[claw1] = 126;//claw will open
	wait1Msec(1000);//for 1 second

	motor[rotateclaw] = 126;//claw will rotate
	wait1Msec(500);//for 0.5 seconds

	while(nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel2] < 5000 && nMotorEncoder[wheel3] < 5000 && nMotorEncoder[wheel4] < 5000)
	{
		motor[wheel1] = -126;//robot will go forward
		motor[wheel2] = 126;//robot will go forward
		motor[wheel3] = 126;//robot will go forward
		motor[wheel4] = -126;//robot will go forward
	}

	motor[claw1] = -126;//claw will close
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will rasie up
	motor[secondarm] = 126;//second arm will rasie up
	wait1Msec(2000);// for 2 seconds

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn right
	motor[wheel3] = -126;//robot will turn right
	motor[wheel4] = -126;//robot will turn right
	wait1Msec(1000);//for 0.6 seconds

	motor[firstarm] = -126;//first arm will lower
	motor[secondarm] = -126;//second arm will lower
	wait1Msec(1000);// for 2 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will rasie up
	motor[secondarm] = 126;//second arm will rasie up
	wait1Msec(2000);// for 2 seconds

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn left
	motor[wheel3] = 126;//robot will turn left
	motor[wheel4] = 126;//robot will turn left
	wait1Msec(2500);//for 0.6 seconds

	while(nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel2] < 5000 && nMotorEncoder[wheel3] < 5000 && nMotorEncoder[wheel4] < 5000)
	{
		motor[wheel1] = -126;//robot will go forward
		motor[wheel2] = 126;//robot will go forward
		motor[wheel3] = 126;//robot will go forward
		motor[wheel4] = -126;//robot will go forward
	}

	motor[claw1] = 126;//claw will grab
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm raise up
	motor[secondarm] = 126;//second arm will raise up
	wait1Msec(3000);// for 2 seconds

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn right
	motor[wheel3] = -126;//robot will turn right
	motor[wheel4] = -126;//robot will turn right
	wait1Msec(2000);//for 0.6 seconds

	motor[firstarm] = -126;//first arm will lower
	motor[secondarm] = -126;//second arm will lower
	wait1Msec(2000);// for 2 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second

	break;
case 3:
	//If count = 1, run the code correspoinding with choice 2
	displayLCDCenteredString(0, "Auto Cubes red-X, blue-driver");
	displayLCDCenteredString(1, "is running!");
	wait1Msec(2000);						// Robot waits for 2000 milliseconds

	//////////////////////////////////////////////////////////////////////////////////////////////////////Auto Cubes red-X, blue-driver

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn
	motor[wheel3] = -126;//robot will turn
	motor[wheel4] = -126;//robot will turn
	wait1Msec(600);//for 0.6 seconds

	motor[firstarm] = 126;//first arm will raise up
	motor[secondarm] = 126;//second arm will raise up
	motor[claw1] = 126;//claw will open
	wait1Msec(1000);//for 1 second

	motor[rotateclaw] = 126;//claw will rotate
	wait1Msec(500);//for 0.5 seconds

	while(nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel2] < 5000 && nMotorEncoder[wheel3] < 5000 && nMotorEncoder[wheel4] < 5000)
	{
		motor[wheel1] = -126;//robot will go forward
		motor[wheel2] = 126;//robot will go forward
		motor[wheel3] = 126;//robot will go forward
		motor[wheel4] = -126;//robot will go forward
	}

	motor[claw1] = -126;//claw will close
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will rasie up
	motor[secondarm] = 126;//second arm will rasie up
	wait1Msec(2000);// for 2 seconds

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn
	motor[wheel3] = 126;//robot will turn
	motor[wheel4] = 126;//robot will turn
	wait1Msec(1000);//for 0.6 seconds

	motor[firstarm] = -126;//first arm will lower
	motor[secondarm] = -126;//second arm will lower
	wait1Msec(1000);// for 2 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm will rasie up
	motor[secondarm] = 126;//second arm will rasie up
	wait1Msec(2000);// for 2 seconds

	motor[wheel1] = -126;//robot will turn right
	motor[wheel2] = -126;//robot will turn
	motor[wheel3] = -126;//robot will turn
	motor[wheel4] = -126;//robot will turn
	wait1Msec(2500);//for 0.6 seconds

	while(nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel1] < 5000 && nMotorEncoder[wheel2] < 5000 && nMotorEncoder[wheel3] < 5000 && nMotorEncoder[wheel4] < 5000)
	{
		motor[wheel1] = -126;//robot will go forward
		motor[wheel2] = 126;//robot will go forward
		motor[wheel3] = 126;//robot will go forward
		motor[wheel4] = -126;//robot will go forward
	}

	motor[claw1] = 126;//claw will grab
	wait1Msec(1000);//for 1 second

	motor[firstarm] = 126;//first arm raise up
	motor[secondarm] = 126;//second arm will raise up
	wait1Msec(3000);// for 2 seconds

	motor[wheel1] = 126;//robot will turn left
	motor[wheel2] = 126;//robot will turn
	motor[wheel3] = 126;//robot will turn
	motor[wheel4] = 126;//robot will turn
	wait1Msec(2000);//for 0.6 seconds

	motor[firstarm] = -126;//first arm will lower
	motor[secondarm] = -126;//second arm will lower
	wait1Msec(2000);// for 2 seconds

	motor[claw1] = -126;//claw will release
	wait1Msec(1000);//for 1 second

	break;
default:
	displayLCDCenteredString(0, "No valid choice");
	displayLCDCenteredString(1, "was made!");
	break;
}

}

And finally here is my pre-auton…

const short leftButton = 1;
const short centerButton = 2;
const short rightButton = 4;

void waitForPress()
{
while(nLCDButtons == 0){}
wait1Msec(5);
}
void waitForRelease()
{
while(nLCDButtons != 0){}
wait1Msec(5);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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, "Auto Skyrise Red");
		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, "Auto Skyrsie Blue");
		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, "Auto Cubes red-driver, blue-X");
		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, "Auto Cubes red-X, blue-driver");
		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;
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bLCDBacklight = true;									// Turn on LCD Backlight
string mainBattery, backupBattery;

while(true)														// An infinite loop to keep the program running until you terminate it
{
	clearLCDLine(0);											// Clear line 1 (0) of the LCD
	clearLCDLine(1);											// Clear line 2 (1) of the LCD

	//Display the Primary Robot battery voltage
	displayLCDString(0, 0, "Primary: ");
	sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
	displayNextLCDString(mainBattery);

	//Display the Backup battery voltage
	displayLCDString(1, 0, "Backup: ");
	sprintf(backupBattery, "%1.2f%c", BackupBatteryLevel/1000.0, 'V');	//Build the value to be displayed
	displayNextLCDString(backupBattery);

	//Short delay for the LCD refresh rate
	wait1Msec(100);
}

}

Well, I guess I did ask for that, next time as an attachment please. Anyway,

in pre auton, you have an infinite loop at the end. You even comment it as an infinite loop :slight_smile: pre-auton never exits so nothing else will run.

    while(true)	 // An infinite loop to keep the program running until you terminate it
    {
        clearLCDLine(0);	 // Clear line 1 (0) of the LCD
        clearLCDLine(1);	 // Clear line 2 (1) of the LCD

        //Display the Primary Robot battery voltage
        displayLCDString(0, 0, "Primary: ");
        sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
        displayNextLCDString(mainBattery);

        //Display the Backup battery voltage
        displayLCDString(1, 0, "Backup: ");
        sprintf(backupBattery, "%1.2f%c", BackupBatteryLevel/1000.0, 'V');	//Build the value to be displayed
        displayNextLCDString(backupBattery);

        //Short delay for the LCD refresh rate
        wait1Msec(100);
    }

So you’re saying I should get rid of the infinite loop? (BTW I copied and pasted some stuff into my pre-auton, so I wasn’t aware of that, and I don’t know how to put my code into an attachment, so I am sorry.) Thanks.

Okay, I figured it out, thank you so much for the help, it is much appreciated!!!

When you go to the advanced reply (click “post reply”, not the box on the bottom) there is an option to “Manage Attachment” where you can add files.

Cool, thanks!