Autonomous code not recognizing motor

The autonomous code is to unfold an arm on the robot. It expands up using pneumatics and then 2 motors “ElbowMotor” 1 and 2 lift the arm up to ready position. The problem is the second motor is not being recognized in the autonomous code, however the motor works fine in the user control.


task autonomous()
{ //Initial unfolding code
  SensorValue[Solenoid1] = 1;
  SensorValue[Solenoid2] = 1;
  wait1Msec(1000);
  while(SensorValue[Quad] > -430) //if the arm is folded/less than desired spot
    motor[ElbowMotor1] = -127;
    motor[ElbowMotor2] = -127; //will not recognize this motor
      if(SensorValue[Quad] == -430) //if it has reached desired spot
      {
      SensorValue[Solenoid1] = 0;
      SensorValue[Solenoid2] = 0;
      motor[ElbowMotor1] = 0;
      motor[ElbowMotor2] = 0;
      }
    while(SensorValue[POT] < 1130) //head motor/game piece lift
    motor[WristMotor1] = -40;
    motor[WristMotor2] = -40;
    if(SensorValue[Quad] == -430)
      {
        motor[ElbowMotor1] = 0;
        motor[ElbowMotor2] = 0;
      }

The proper structure for a while loop is:

while(condition)
{
code to be repeated
}

When you don’t include the curly braces, like with your “while(SensorValue[Quad] > -430)” loop, it only repeats the first command immediately following the loop. Consequently, only the first command with the first motor is being turned on.