How to drive dc motor using L293D with arduino

How to drive dc motor using L293D with arduino


First make ground and Vcc connections on the breadboard from arduino.


Before proceeding further it is recommended that you read and understand the pin diagram of L293D

Pin diagram of L293D






Enable 1


Input 1

Digital output pin.Pin no is upto you (I have used 3)

Output 1

motor wire 1





Output 2

Motor wire 2

Input 2

Digital output pin.Pin no is upto you(i have used 4)


Power supply for motors




The below image shows  SN754410 H-bridge which is compatible with L293D and  it is the pin to pin replacement.So that means we can use L293D in the circuit made using SN754410 and vice versa

Now make connections for driving the motor as shown in below figure

In this method we are using external power supply for the arduino board and the same power supply is being used by the motors.i.e we are powering the motors from Vin on arduino.


Note: Using the below circuit will power your motor with 9V so you should use a 9V or a higher voltage motor.


However you can also use the USB power to power the arduino board and an external power supply to power the motors directly

Other option is if you want to use two power(battery) supply you can just simply connect a 9V battery to the power plug of arduino board.In this way the arduino will get 9V and the motors will get 6V( or whatever voltage you used) through the second battery.(For the below circuit)




// Community of Robots//

//Dc motor example code//

int motorpin1 = 3;                  //define digital output pin no.

int motorpin2 = 4;                  //define digital output pin no.

void setup () {

  pinMode(motorpin1,OUTPUT);        //set pin 3 as output

  pinMode(motorpin2,OUTPUT);        // set pin 4 as output


void loop () {





If you will copy paste the above code then motor will run in one direction.To drive the motor in opposite direction you just need to put HIGH instead of LOW and vice versa.


Got any problem ? post a comment



yecidmv's picture

Mil gracias!!!!

Jumm muchas gracias este tutorial me ayudo de mucho en mi proyecto("Robot Detector de Minas controlado por BLUETOOTH") puesto que no sabia como era  el control por medio de un puente H para una bateria independiente me ahorraste mucho tiempo y dinero ; estaba decidido de hacerloscon tip 120 o con reles pero esto me ayudo!!!!!!!!!!!



yumi1996's picture

Low Power

When connected directly to the power source (4 AA batteries in series) my motors turn very quickly and provide enough power to turn the treads. However, after writing the appropriate program and using this setup, the power through the dirver (l293d) is not sufficient to turn our treads. What is happening?


Chuck_EarthBender's picture

A question

Oh, first of all I really like yous post, I have learned a lot of arduino here, but now I have a little question about the connection. I have an arduino UNO, and I want to connect it to a dc motor that is bigger than the one you have show us. So, I need to know, how I will connect the ground, if we know that the voltage on the pin 8 of the L293D receives the motor´s required voltage. It´s my first arduino and I really want to keep it alive...hehe. I don´t want to burn it. 

gunnlaugursig's picture

Motor with build in potentiometer


I've build this circuit and tested with my dc motor. This is a steering motor from an old RC car and has a build in potentiometer for calibration to limit the steering movement.

How would I connect the potentiometer to the circuit or the arduino so I can use it to steer the car?


Thank you.


komal's picture

want to drive dc using ps2

Hi, actually i have already interfaced (ps2)playstation2 controller with arduino uno.. now i want drive dc motors interfacing with arduino uno by ps2 .. so how should i do it?? i m not  understanding how to intermix that code of ps2 and dc motor ..thank u 

ajimzack's picture

power supply problem

hi, i already connect ardunio and motor thourgh l293 d..but the problem is when i already upload the coding,the motor will not run immediately.i need to rotate first only then the motor will work..i use 2 motor left and right. the power supply is through the usb and 9vbattery.

Neneson's picture


Realizo el circuito y cuando mido los pins 3 y 6 con el voltimetro, me aparecen los 5V de alimentacion

Sin embargo cuando conecto el motor, el voltage cae a 0,5 y el motor no funciona

Muchas gracias de antemano por su ayuda


Realize the circuit and when I measure pins 3 and 6 with the voltmeter, I appear 5V feed

But when I connect the motor, the voltage drops to 0.5 and the engine does not work

Thank you very much in advance for your help

kawal's picture

Neneson, I am not able to


I am not able to understand it properly.Please provide some more details about your setup.


mtaram's picture

A question

Which software has been used to make the awesome illustrations of the Arduino and the breadboard layout above? I have searched and downloaded several but nothing looks this good.

MtaraM (aka Utkarsh)

Solution Architect by profession, Engineer by thought.

kawal's picture

Add a new comment

Login or register to post comments

New to community of robots ?