user46973: 
I use 2 gearbox motors with 2 wheels .. but if I try to run it, he can not walk straight. he always moves slightly to the right or to the left.
How i fix it ?

user27653: Likely the two gearbox motors you have are running at slightly different speeds for the same voltage. This is probably within normal tolerances, given that you say it moves slightly to the right or left.
You can use PWM-capable pins for motor control so you can adjust how fast the motors turn. If you do this, you have a couple of paths you can take:
You can, through trial-and-error, lower the PWM value (analogWrite(pin, speed)) for the faster-turning motor so that they both turn at the same speed.
or
You can find some way to detect the actual rotational speed of each motor and do the calibration in real-time on the Arduino. This might mean adding new sensors such as rotary encoders (mechanical or optical), or light-break sensors, etc.

46973: <p><img src="https://i.stack.imgur.com/JCGNx.jpg" alt="enter image description here"></p>

<p>I use 2 gearbox motors with 2 wheels .. but if I try to run it, he can not walk straight. he always moves slightly to the right or to the left.</p>

<p>How i fix it ?</p>
 27653: <p>Likely the two gearbox motors you have are running at slightly different speeds for the same voltage. This is probably within normal tolerances, given that you say it moves <em>slightly</em> to the right or left.</p>

<p>You can use PWM-capable pins for motor control so you can adjust how fast the motors turn. If you do this, you have a couple of paths you can take:</p>

<p>You can, through trial-and-error, lower the PWM value (<code>analogWrite(pin, speed)</code>) for the faster-turning motor so that they both turn at the same speed.</p>

<p>or</p>

<p>You can find some way to detect the actual rotational speed of each motor and do the calibration in real-time on the Arduino. This might mean adding new sensors such as rotary encoders (mechanical or optical), or light-break sensors, etc.</p>
