How to program controller like video game? Help

I’m trying to program my controller in the same way that it would be in a video game (left stick is forward/ back and right stick is for turning left/ right). I’ve set up my code so that channel 3 makes the robot go forward/ back and channel 1 makes the robot turn left/ right while also being connected to the same 2 motors.

task main ()
{

while(1 == 1)
{
	motor[leftMotor] = - vexRT[Ch3];  // forward and back
	motor[rightMotor] = - vexRT[Ch3];  // forward and back

	motor[rightMotor] = vexRT[Ch1]; // left and right
	motor[leftMotor] = - vexRT[Ch1]; // left and right

	if(vexRT[Btn8R] == 1)       	//If button 8L is pressed...
	{
		motor[backMotor] = 127;    	//...move wheel left.
	}
	else if(vexRT[Btn8L] == 1)  	//Else, if button 8R is pressed...
	{
		motor[backMotor] = - 127;   	//...move wheel right.
	}
	else                      		//Else (neither button is pressed)...
	{
		motor[backMotor] = 0;      	//...stops wheel.
	}


	if(vexRT[Btn5U] == 1)       	//If button 5U is pressed...
	{
		motor[handMotor] = 127;    	//...raise the hand.
	}
	else if(vexRT[Btn5D] == 1)  	//Else, if button 5D is pressed...
	{
		motor[handMotor] = - 127;   	//...lower the hand.
	}
	else                      		//Else (neither button is pressed)...
	{
		motor[handMotor] = 0;      	//...stop the hand.
	}


	if(vexRT[Btn6U] == 1)       	//If button 6U is pressed...
	{
		motor[armMotors] = 127;    	//...raise the arm.
	}
	else if(vexRT[Btn6D] == 1)  	//Else, if button 6D is pressed...
	{
		motor[armMotors] = - 127;   	//...lower the arm.
	}
	else                      		//Else (neither button is pressed)...
	{
		motor[armMotors] = 0;      	//...stop the arm.
	}

}

}  

My robot has no trouble turning left and right (Ch1) but for some reason whenever I try making it go forward or back (Ch3) the motors seem weaker and doesn’t move the robot at all. I’ve switched the channels to see if there was something wrong with the controller but even then it still doesn’t work. I think it’s because I have 2 different channels connected to same motors and that’s causing the trouble. Is there some way that I can get passed this problem in the coding or programming?

First, let’s put this in code brackets.
I am not absolutely sure, but I think that maybe this extra negative in the 5th or 6th line of code may be messing it up, try removing it. My thought is that if the left and right movements are working, and you only have one negative in those lines of code, you should remove one of the negatives in the forward and backward movements.

task main ()
{
	while(1 == 1)
	{
		motor[leftMotor] = - vexRT[Ch3]; // forward and back
		motor[rightMotor] = - vexRT[Ch3]; // forward and back

		motor[rightMotor] = vexRT[Ch1]; // left and right
		motor[leftMotor] = - vexRT[Ch1]; // left and right

		if(vexRT[Btn8R] == 1) //If button 8L is pressed...
		{
			motor[backMotor] = 127; //...move wheel left.
		}
		else if(vexRT[Btn8L] == 1) //Else, if button 8R is pressed...
		{
			motor[backMotor] = - 127; //...move wheel right.
		}
		else //Else (neither button is pressed)...
		{
			motor[backMotor] = 0; //...stops wheel.
		}

		if(vexRT[Btn5U] == 1) //If button 5U is pressed...
		{
			motor[handMotor] = 127; //...raise the hand.
		}
		else if(vexRT[Btn5D] == 1) //Else, if button 5D is pressed...
		{
			motor[handMotor] = - 127; //...lower the hand.
		}
		else //Else (neither button is pressed)...
		{
			motor[handMotor] = 0; //...stop the hand.
		}

		if(vexRT[Btn6U] == 1) //If button 6U is pressed...
		{
			motor[armMotors] = 127; //...raise the arm.
		}
		else if(vexRT[Btn6D] == 1) //Else, if button 6D is pressed...
		{
			motor[armMotors] = - 127; //...lower the arm.
		}
		else //Else (neither button is pressed)...
		{
			motor[armMotors] = 0; //...stop the arm.
		}
	}

}  

Try making it simpler with something like this…


Task main ()
{

#define C1RX = VexRT [ch1];
#define C1LY = VexRT [ch3];

  While (true)
  {
  Motor [rightMotor] = C1LY + C1RX;
  Motor [leftMotor] = C1LY + C1RX;
  }

}

I’m not sure what the motor is. If it’s one of the motor is on your drive then just put it in the wild look like I have the other. If this doesn’t work it might be because some of your Motors are reversed on your drive. Anyway, I hope this helps :slight_smile:

Oh… Aiden beat me to it :stuck_out_tongue:

Nevermind then. If Aiden’s code works then go ahead and use his :slight_smile: