Two identical-looking DC motors never run at exactly the same speed with the same PWM. The robot curves toward the slower side.
What the message means
Gear friction, supply drop and small motor differences change the speed. Open-loop PWM does not correct them.
Fix it in this order
- Check that both wheels are the same size and spin freely.
- Add a trim factor: scale the PWM for one motor until the robot runs straight, as a quick fix.
- Check both motors take the same supply voltage at the driver outputs.
- For a lasting fix use encoders and a small speed control loop for each wheel.
- Test on a flat floor, at the speed you will really use.
Why it happens
Two motors given the same PWM value rarely turn at the same speed, because of differences in the motors, gearboxes, wheels and driver. The robot curves toward the slower side.
A quick fix is a trim factor on one side. A better fix is feedback: read encoders and adjust each side to the same measured speed.
float TRIM_LEFT = 1.00; // try 0.95 to 1.05
setMotors((int)(speed * TRIM_LEFT), speed); // your function: left, right
Example sketch: change pins and values for your own wiring. It has not been bench-tested on your hardware.
If you see this, do this
| You see | Do this |
|---|---|
| Drift changes with battery charge | Use feedback instead of a trim. |
| Always drifts the same way | Mechanical or trim problem. |
Related
encoder counts, wheel speed calculator.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.