How to Control Two Motors with Arduino and Create Arduino Controlled Car

2-Motors-circuit

We knew how to control a DC motor using Arduino. And now we are studying how to control two motors using the same IC and configuration.

This setup can help you make Arduino controlled car. You can assemble the two motors as the main drive for the car.

In this post, the code controls the motors at the same time in the same direction. But you can use this code to control the motors in different direction or to move right or left.

Circuit

This is the circuit as assembled using Arduino and L293D Hbridge. But you can simply connect Arduino UNO Board to Arduino Motor Shield and use the same code and configuration.

Code

void setup()
{
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);

pinMode(6, OUTPUT);
pinMode(5, OUTPUT);

}

void loop()
{
digitalWrite(11, HIGH);
digitalWrite(6, HIGH);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(11, LOW);
digitalWrite(6, LOW);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(10, HIGH);
digitalWrite(5, HIGH);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(10, LOW);
digitalWrite(5, LOW);

delay(1000); // Wait for 1000 millisecond(s)

}

Tinker Simulation

Here we can see the simulation and the circuit using Tinkercad.

And that concludes this episode with Arduino connection to the L293D HBridge to make a simple Arduino controlled car.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top