User Control Loop [HELP!!!]

Hey, I’m trying to make a user control loop and I have a slight issue. The button in the “else if” loop won’t work. It isn’t a controller issue, as I have switched the buttons and it has worked for the respective button, not it’s opposite. Any help is appreciated. Thanks in advance.
P.S. ik my code is bad cool :slight_smile:


#pragma config(Motor,  port2,           leftSideDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           rightSideDrive, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port5,           leftArm,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           rightArm,      tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           intake,        tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           leftTurntable, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port9,           rightTurntable, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

void liftControl(int leftSide, int rightSide)
{
	motor[leftTurntable] = leftSide;
	motor[rightTurntable] = rightSide;

}

void armControl(int armLeft, int armRight)
{
	motor[leftArm] = armLeft;
	motor[rightArm] = armRight;
}

task main()
{
	while (1 == 1)
	{
	
		if(vexRT[Btn6DXmtr2] == 1)
			{
				motor[rightArm] = 127;
			}
			else if(vexRT[Btn6UXmtr2] == 1)
			{
				motor[rightArm] = -127;
			}
			else 
			{
				motor[rightArm] = 0;
			}
			
			if(vexRT[Btn6UXmtr2] == 1)
		{
			motor[rightArm] = -127;
		}
		else if(vexRT[Btn6DXmtr2] == 1)
		{
			motor[rightArm] = 127;
		}
		else 
		{
			motor[rightArm] = 0;
		}
	
	}
}

You are testing the same two buttons in two almost identical if statements. Delete one of the two if…else if…else sets and the problem should go away.

You also are never sending motor values to the left arm motor… try:


void armControl(int armPower)
{
	motor[leftArm] = armPower;
	motor[rightArm] = armPower;
}

task main()
{
	while (1 == 1)
	{
	
		if(vexRT[Btn6DXmtr2] == 1)
			{
				armControl( 127 );
			}
			else if(vexRT[Btn6UXmtr2] == 1)
			{
				armControl( -127 );
			}
			else 
			{
				armControl( 0 );
			}
				
	}
}