ports not working - captainespinoza read this

The problem is completely with the code.

specifically, the use of statements like this

      if(vexRT[Btn5D]==1)
      {
        motor[TopLeftLift] = 127;
      }
      else if(vexRT[Btn5U]==1)
      {
        motor[TopLeftLift] = -127;
      }
      else if(vexRT[Btn5D]==0)
      {
        motor[TopLeftLift] = 0;
      }
      else if (vexRT[Btn5U] ==0)
      {
        motor[TopLeftLift] = 0;
      }

The final “else if” will never execute, you have a bunch of code in the final “else if” of this part.

        else if(vexRT[Btn7D]==0)
        {
          motor[TestMotor] = 0;
        }
        else if (vexRT[Btn7U] ==0)
        {
          motor[TestMotor] = 0;

          //IntakeMotor----------------------------------------------

          if(vexRT[Btn8D]==1)

which essentially stops all the code for the intake, right top and right left motors from executing. Here is a revised version that works.

#pragma config(Motor,  port1,           frontLeftMotor, tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           TestMotor,     tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port3,           IntakeMotor,   tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port4,           TopRightLift,  tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port5,           BottomRightLift, tmotorServoContinuousRotation, openLoop, reversed, driveRight)
#pragma config(Motor,  port6,           TopLeftLift,   tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port7,           BottomLeftLift, tmotorServoContinuousRotation, openLoop, reversed, driveLeft)
#pragma config(Motor,  port8,           frontRightMotor, tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port9,           backRightMotor, tmotorServoContinuousRotation, openLoop, driveRight)
#pragma config(Motor,  port10,          backLeftMotor, tmotorVex393_HBridge, openLoop, reversed)

task main()
{
    while (true)
        {
        //Program for Riverdale High School Robotics Team Robot 4099-C
        //Mecanum Wheels Cake
        motor[frontRightMotor] = vexRT[Ch3] - vexRT[Ch1] - vexRT[Ch4];
        motor[backRightMotor]  = vexRT[Ch3] - vexRT[Ch1] + vexRT[Ch4];
        motor[frontLeftMotor]  = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
        motor[backLeftMotor]   = vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
    
        //Left Top--------------------------------------
        if(vexRT[Btn5D]==1)
          {
          motor[TopLeftLift] = 127;
          }
        else if(vexRT[Btn5U]==1)
          {
          motor[TopLeftLift] = -127;
          }
        else
          {
          motor[TopLeftLift] = 0;
          }
      
        //Bottom Left---------------------------------------------
        if(vexRT[Btn5D]==1)
          {
          motor[BottomLeftLift] = 127;
          }
        else if(vexRT[Btn5U]==1)
          {
          motor[BottomLeftLift] = -127;
          }
        else
          {
          motor[BottomLeftLift] = 0;
          }
        //Test Port------------------------------------------
        if(vexRT[Btn7D]==1)
          {
           motor[TestMotor] = 127;
          }
        else if(vexRT[Btn7U]==1)
          {
          motor[TestMotor] = -127;
          }
        else
          {
          motor[TestMotor] = 0;
          }
                
        //IntakeMotor----------------------------------------------
    
        if(vexRT[Btn8D]==1)
          {
          motor[IntakeMotor] = 127;
          }
        else if(vexRT[Btn8U]==1)
          {
          motor[IntakeMotor] = -127;
          }
        else
          {
          motor[IntakeMotor] = 0;
          }          
              
        //Right Top------------------------------------------------
        if(vexRT[Btn6D]==1)
          {
          motor[TopRightLift] = 127;
          }
        else if(vexRT[Btn6U]==1)
          {
          motor[TopRightLift] = -127;
          }
        else
          { 
          motor[TopRightLift] = 0;
          }    
                
    
        //Right Left--------------------------------------------
        if(vexRT[Btn6D]==1)
          {
          motor[BottomRightLift] = 127;
          }
        else if(vexRT[Btn6U]==1)
          {
          motor[BottomRightLift] = -127;
          }
        else
          {
          motor[BottomRightLift] = 0;
          }
      }
}
1 Like