Wheels programming not working

Wheel 1 wheel 9

Wheel3 wheel 10

Im making a robot for competition and i was trying to have wheel 1 and 3 to go forward and wheel 9 and 10 go backward when i press the button 8R. Here is the program:

if(vexRt[Btn8R] == 1)
{
	motor[port9] = -127
	motor[port1] = -127
	
	motor[port10] = 127
	motor[port3] = 127 

But instead wheel 1 and 3 work fine. Wheel 2 stutters when it is trying to go and wheel 10 does nothing.

We have a program for the wheel connected to the joysticks and it works perfectly

{
while(1 == 1)
{

motor[port1] = vexRT[Ch2];         // front right motor move forward if joystick pushed forward
motor[port3]  = vexRT[Ch2];        // back right motor move forward if joystick pushed forward








motor[port9] = vexRT[Ch3];        // back left motor move fourward if joystick is pushed forward
motor[port10]  = vexRT[Ch3];      // front left motor move fourward if joystick is pushed forward

. All the motors run fine on the joysticks, even motors 10 and 2 so it’s not the motors. I changed the buttons and that didn’t change anything so it’s not the buttons. Any suggestion about changing the program would be great and if this happened to you what did you do?

Thanks

What is probably happening is that the button code and the joystick code is in the same loop, so the program checks the state of the button and sets a power level, then checks the joysticks and changes the power level. The stuttering you are seeing is caused by sending two different power levels alternately to a motor in a very short period of time.

Your program needs to do something like this:

If a button is pressed,
Do this stuff for the button
Else
Do this other stuff for the joystick
End If

If you post your whole program, you will get a more-specific answer.

Also, it would be easier for us to help you if you included your code in code brackets as such…

if(vexRt[Btn8R] == 1)
{
motor[port9] = -127
motor[port1] = -127

motor[port10] = 127
motor[port3] = 127
while(1 == 1)
{

motor[port1] = vexRT[Ch2]; // front right motor move forward if joystick pushed forward
motor[port3] = vexRT[Ch2]; // back right motor move forward if joystick pushed forward

motor[port9] = vexRT[Ch3]; // back left motor move fourward if joystick is pushed forward
motor[port10] = vexRT[Ch3]; // front left motor move fourward if joystick is pushed forward

Here is the latest code. It still does not work…not sure what we’re doing wrong.

task main()

{
while(1 == 1)
{
if(vexRT[Btn8R] ==1 && vexRT[Ch2 && Ch3] ==0)
{
motor[port1] = 127;
motor[port9] = 127;

motor[port3] = -127;
motor[port10] = -127;

{
if(vexRT[Ch2 && Ch3] != 0)
{
motor[port1] = vexRT[Ch2]; // front right motor move forward if joystick pushed forward
motor[port3] = vexRT[Ch2]; // back right motor move forward if joystick pushed forward

motor[port9] = vexRT[Ch3];        // back left motor move forward if joystick is pushed forward
motor[port10]  = vexRT[Ch3];      // front left motor move forward if joystick is pushed forward

}
if(vexRT[Btn6U]==1)
{
motor[MotorArm] = 127; // arm moves up if button 6 U is pushed
motor[MotorArm2] = 127; // arm moves up if button 6 u is pushed

}
else if(vexRT[Btn6D] == 1)
{
	motor[motorArm] = -127;      // arm moves down if button 6 D is pushed
	motor[motorArm2] = -127;      // arm moves down if button 6 D is pushed
}
else
{
	motor[motorArm] = 0;        // if button 6 D or U is not pushed the arm will go no where
	motor[motorArm2] = 0;       // if button 6 D or U is not pushed the arm will go no where
}


  if(vexRT[Btn5U]==1)
{
	motor[MotorMan] = 127;     // arm moves up if button 6 U is pushed
	motor[MotorMan2] = 127;      // arm moves up if button 6 u is pushed






}
else if(vexRT[Btn5D] == 1)
{
	motor[Motorman] = -127;      // arm moves down if button 6 D is pushed
	motor[MotorMan2] = -127;      // arm moves down if button 6 D is pushed
}
else
{
	motor[MotorMan] = 0;          // if the button 5 U or D is not pushed the scoop goes nowhere
	motor[MotorMan2] = 0;         // if the button 5 U or D is not pushed the scoop goes nowhere
}

}
}
}
}

When downloaded nothing happened. Any ideas?

When posting code, always use the </> symbol, it helps us to see it as it was meant to

It looks like your braces are off.

task main()

{
while(1 == 1)	
{
if(vexRT[Btn8R] ==1 && vexRT[Ch2 && Ch3] ==0)	
{
motor[port1] = 127;
motor[port9] = 127;

motor[port3] = -127;
motor[port10] = -127;
{  //<--- Right here.  The left brace causes the following code to be nested in the previous if. I think this should be a right brace. }
if(vexRT[Ch2 && Ch3] != 0)
{
motor[port1] = vexRT[Ch2]; // front right motor move forward if joystick pushed forward
motor[port3] = vexRT[Ch2]; // back right motor move forward if joystick pushed forward

motor[port9] = vexRT[Ch3]; // back left motor move forward if joystick is pushed forward
motor[port10] = vexRT[Ch3]; // front left motor move forward if joystick is pushed forward
}
if(vexRT[Btn6U]==1)
{
motor[MotorArm] = 127; // arm moves up if button 6 U is pushed
motor[MotorArm2] = 127; // arm moves up if button 6 u is pushed

}
else if(vexRT[Btn6D] == 1)
{
motor[motorArm] = -127; // arm moves down if button 6 D is pushed
motor[motorArm2] = -127; // arm moves down if button 6 D is pushed
}
else
{
motor[motorArm] = 0; // if button 6 D or U is not pushed the arm will go no where
motor[motorArm2] = 0; // if button 6 D or U is not pushed the arm will go no where
}

if(vexRT[Btn5U]==1)
{
motor[MotorMan] = 127; // arm moves up if button 6 U is pushed
motor[MotorMan2] = 127; // arm moves up if button 6 u is pushed

}
else if(vexRT[Btn5D] == 1)
{
motor[Motorman] = -127; // arm moves down if button 6 D is pushed
motor[MotorMan2] = -127; // arm moves down if button 6 D is pushed
}
else
{
motor[MotorMan] = 0; // if the button 5 U or D is not pushed the scoop goes nowhere
motor[MotorMan2] = 0; // if the button 5 U or D is not pushed the scoop goes nowhere
}
}
}
}
}