Unresponding Motor

One motor is working and another motor isn’t responding to the controller

Code=

task usercontrol()
{
while (true)
{
while (1 == 1)

	motor[RightMotor] = vexRT[Ch2];

	motor[LeftMotor] = vexRT[Ch3];

	if(vexRT[Btn6D] == 1)
	{
		motor[LauncherR] = 127;
	}
	else
	{
		motor[LauncherR] = 0;
	}
	//LauncherRight motor is on Btn 7u*//
	if(vexRT[Btn5D] == 1)
	{
		motor[LauncherL] = 127;
	}
	else
	{
		motor[LauncherL] = 0;
	}
	//LauncherLeft motor is on Btn 8u*//
	if(vexRT[Btn6U] == 1)
	{
		motor[ARight] = 127;
	}
	else
	{
		motor[ARight] = 0;
	}
	//Accumulator is on 6U*//
	if(vexRT[Btn5U] == 1)
	{
		motor[AB] = 127;
	}
	else
	{
		motor[AB] = 0;
	}
}

}

I think it could be because you have one while loop inside another while loop

I think the code looks fine (next time use the CODE tags by clicking the “</>” button so it’s easier to read), and the doubled while loops are not necessary but shouldn’t have an effect. Are you sure that the motors in question and their ports on the cortex are working? Try a really simple program to test each port individually, something like this for each motor:


motor[rightMotor] = 127;
wait1msec(1000);
motor[rightMotor] = 0;

If the rest of your code doesn’t respond either, then this might be your problem. You are missing the curly braces { } for the second while loop (which you don’t even need, because it has the same function as the first one). When a loop of any kind does not have curly braces immediately following it, only the line immediately after the loop is inside the loop. Therefore, your Cortex treats the code as though this is it:


task usercontrol()
{
while (true)
{
while (1 == 1)
{
motor[RightMotor] = vexRT[Ch2];
}
motor[LeftMotor] = vexRT[Ch3];
//rest of code, this is all that matters

Because 1==1 is always true, you never exit the loop containing the right motor control. That particular feature is occasionally useful, but I usually find it really irritating. To fix this, remove the


while(1==1)

from the inside of the other while loop.