Reprogramming issue

When I reprogrammed my robot and downloaded my program to my cortex, none of the motors would go. I don’t know what to do but suspect it is the programming. Please help me and here is my program:

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include “Vex_Competition_Includes.c” //Main competition background code…do not modify!

/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.

bStopTasksBetweenModes = true;

// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...

}

/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task autonomous()
{
// …
// Insert user code here.
// …
// Remove this function call once you have “real” code.
}

/////////////////////////////////////////////////////////////////////////////////////////
//
// User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task usercontrol()

{
while (true)
//drive
motor[10] = vexRT(Ch2);

motor[6] = vexRT(Ch3);
//Arm lift
if (vexRT[Btn5U] == 1)
{
	motor[port4] = 127;
	motor[port2] = 127;
	motor[port3] = 127;
	motor[port5] = 127;
}


else if (vexRT[Btn5D] == 1)
{
	motor[port4] = -127;
	motor[port2] = -127;
	motor[port3] = -127;
	motor[port5] = -127;
}
else
{
	motor[port4] = 0;
	motor[port2] = 0;
	motor[port3] = 0;
	motor[port5] = 0;

//intake
}
if (vexRT[Btn6U] == 1)
{
motor[port7] = -40;
motor[port8] = -40;
}
else if (vexRT[Btn6D] == 1)
{
motor[port7] = 40;
motor[port8] = 40;
}
else
{
motor[port7] = 0;
motor[port8] = 0;
}

}

The problem is that you’ve left out some braces. In C-like languages, the behavior of a while loop without braces is as follows:

while(true)
  statement; //Is repeated--this is "inside" the loop
  statement; //Is not repeated, since it's outside the loop
statement; //Is not repeated, since it's outside the loop

That is, a loop without braces only repeats the stuff until the next semicolon, nothing else. Notice that indentation doesn’t matter.

If you want to repeat a whole chunk of code, use braces as follows:

while(true) {
  statement; //Is repeated--this is "inside" the loop
  statement; //Is repeated--this is "inside" the loop
}
statement; //Is not repeated, since it's outside the loop

first of all, make sure you’re using a competition switch. If you dont have one, then copy and paste your driver control and #pragmas(paste the pragmas at the top, so you dont have to enter all of the motors and sensors again in the window thing. Put your driver control in a while(true){ } loop and see if that works. Second of all, make sure your motors are in the right ports and are reversed correctly. Third of all move the wheels manually and make sure all of them are making the usual motor noise, if they aren’t then there is something wrong with the build(axles aren’t in the motor) or the motors are messed up.
Hope I helped…good luck!:slight_smile:

If you cut and pasted some code to make a new file, be sure that your motors and sensors got assigned to their proper ports in the new file. Check on this by going to the “Motors and Sensors” tab. Sometimes kids will cut and paste their pragma statements but the ports will not get re-assigned properly unless you compile the code and then save it.

When posting code on the forum, remember to use the code tags to enclose your code so the formatting is preserved.

The code tag thingy is in the upper right corner…

https://vexforum.com/attachment.php?attachmentid=8620&d=1412376960

RoboDesigners in post #2. The only code you will execute is the first while statement

while (true)
    //drive 
    motor[10] = vexRT(Ch2);

Just a friendly word of advice, you should probably reduce the speed of those motors for your chassis. This can cause the robot to overheat and lose precious time in the competitions!