Quote:
Originally Posted by Darkknight512
It doesn't seem to make sense to me that the robot goes backwards when the PWM's are switched.
|
Think about which way the motors turn in order for the robot to move forwards. Drivetrain designs with both motors going the same direction are vanishingly rare. Almost invariably, one spins clockwise and the other spins counterclockwise.
When you swap the motor control, you're telling each motor to turn the way the other one used to. That runs the robot in the other direction.
Just look at the code, and at the robot wiring, and make sure that the PWM signal configured as the left motor is the same one physically connected to the left motor. Do the same for the right motor. Then if either side of the robot runs in the wrong direction, invert that motor's control in the code.