Programming Help- 2 Motor 2 joystick Drive System

Can someone help us use change the default code from a one joystick operation to a two joystick two motor drive system?

We will be using a tank drive system. We would like to see some sample code.

Team 166 just posted some of there code, and it included two-joystick drive. May be worth checking out!

If you’re using a tank drive, it’s simple. Pretend the left motor is pwm01 and the right motor is pwm02. Call the left joystick p1_y and the right joystick p2_y (because y is the forwards-backwards direction). Then the code is simply:


pwm01 = p1_y;
pwm02 = p2_y;

Note: you may need 255-p1_y if the left motor moves backwards. Same goes for the right motor: 255-p2_y.

When both joysticks are forwards, both motors are forward and the robot goes forward. When both are back, the robot goes backwards. When one is forward and one is backwards, the motors move in opposite directions and the robot twists clockwise or counterclockwise.