View Single Post
  #3   Spotlight this post!  
Unread 02-02-2008, 14:08
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: Programming Help- 2 Motor 2 joystick Drive System

Quote:
Originally Posted by OMAR_567 View Post
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.
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:

Code:
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.