Limit switch programing help

I am trying to program limit switches to stop my arm from going up and going down. I must be doing something wrong because my my switches won’t stop the motion and my robotC crashed every time I try to download to the robot. I have two limit switches controlling two motors.

#pragma config(Sensor, dgtl11, btmLimit, sensorTouch)
#pragma config(Sensor, dgtl12, topLimit, sensorTouch)
#pragma config(Motor, port1, , tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, leftArm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, FL, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port5, FR, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port6, BL, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port7, BR, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port8, rightArm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, , tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main() {
while(true) {
if(topLimit == true){
if(vexRT[Btn6U] == 1){
motor[rightArm] = -75;
motor[leftArm] = -75;
}
else{
motor[rightArm] = 0;
motor[leftArm] = 0;
}
}
else if(btmLimit == true){
if(vexRT[Btn6D] == 1){
motor[rightArm] = 75;
motor[leftArm] = 75;
}
else{
motor[rightArm] = 0;
motor[leftArm] = 0;
}
}
else{
if(vexRT[Btn6U] == 1){
motor[rightArm] = -75;
motor[leftArm] = -75;
}
else if(vexRT[Btn6D] == 1){
motor[rightArm] = 75;
motor[leftArm] = 75;
}
else{
motor[rightArm] = 0;
motor[leftArm] = 0;

		}

Instead of using “topLimit” and “btmLimit” directly you need to read their values using SensorValue.

To test if the top limit switch is pressed use

if( SensorValue[topLimit] == 1 ) {
  // switch pressed
}
else {
  // not pressed
}