Limit switch Help

Hey, so my team has been trying to program a limit switch, in driver control, so that when we touch the limit, the arm can’t go down no more, but it can raise and run the chassis. But we haven’t made any progress, help??

 while (true)
  {
  	 motor[motoralfrentederecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoralfrenteizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motoratrasderecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoratrasizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motorbrazoderechoabajoimverso] = vexRT[Ch2];
     motor[motorbrazoderecho] = vexRT[Ch2];
     motor[motorbrazoderechoinverso] = vexRT[Ch2];
     motor[motorbrazoizquierdo] = vexRT[Ch2];
     motor[motorbrazoizquierdoabajo] = vexRT[Ch2];
     motor[motorbrazoizquierdoinverso] = vexRT[Ch2];



    if(vexRT[Btn6U] == 1)
    {
    	SensorValue[solenoid] = 1;
    }

    else
    {
    	SensorValue[solenoid] = 0;
    }
   
    while(SensorValue[limit] == 1)
    {
     motor[motoralfrentederecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoralfrenteizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motoratrasderecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoratrasizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motorbrazoderechoabajoimverso] = 0;
     motor[motorbrazoderecho] = 0;
     motor[motorbrazoderechoinverso] = 0;
     motor[motorbrazoizquierdo] = 0;
     motor[motorbrazoizquierdoabajo] = 0;
     motor[motorbrazoizquierdoinverso] = 0;
     wait1Msec(10);
    
   }
     	 motor[motoralfrentederecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoralfrenteizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motoratrasderecho] = vexRT[Ch3] - vexRT[Ch4];
     motor[motoratrasizquierdo] = vexRT[Ch3] + vexRT[Ch4];
     motor[motorbrazoderechoabajoimverso] = vexRT[Ch2];
     motor[motorbrazoderecho] = vexRT[Ch2];
     motor[motorbrazoderechoinverso] = vexRT[Ch2];
     motor[motorbrazoizquierdo] = vexRT[Ch2];
     motor[motorbrazoizquierdoabajo] = vexRT[Ch2];
     motor[motorbrazoizquierdoinverso] = vexRT[Ch2];
   
    	
  

You have your main drive and lift code written twice, so delete one of those. I would recommend testing for your limit switch with an if statement:


while(true)
{
// arcade drive control code on Ch3 + 4

// solenoid control on Btn6U

// lift control on Ch2
if (SensorValue[limit] == 1 && vexRT[Ch2] < 0) // if the switch is closed and the signal is negative
{
// set lift motors to 0
}
else
{
// set the lift motors to Ch2
}
}