Introduction: Control Your Motors With L293D and Arduino

Picture of Control Your Motors With L293D and Arduino

After long research and trial and error, I have came up to a new walkthrough regarding this nice chip, the L293D.

Each project is one project and each one has its own unique power configurations, so you must be aware of the best battery choice and how to distribute voltage through your robot.

I strongly advice you to read the following articles:

Picking Batteries for your Robot
Once you've decided on batteries, how do you regulate the voltage


L293D gives you the possibility to control two motors in both directions - datasheet

Step 1: Basic Implementation

Picture of Basic Implementation

This is the most basic implementation of the chip.

As you can see, a 5V Voltage Regulator is between the battery and pins 1, 9, 16.

Pin 8 gets power before the VReg, if your motor needs for example 6V you should put 6V directly in this pin, all the other pins should not get more than 5V.

This will work with no problem at all, but if you want to do the right implementation take a look at the next example:

Step 2: Advanced Implementation

Picture of Advanced Implementation

This is the correct Implementation (with the capacitors), and note that pin 8 is feeded by unregulated voltage. This means that if your motors need more than 5V, you should power this pin with that amount of voltage, and the rest of the circuit with 5V.

Step 3: Arduino Code

// Use this code to test your motor with the Arduino board:

// if you need PWM, just use the PWM outputs on the Arduino
// and instead of digitalWrite, you should use the analogWrite command

// --------------------------------------------------------------------------- Motors
int motor_left[] = {2, 3};
int motor_right[] = {7, 8};

// --------------------------------------------------------------------------- Setup
void setup() {

// Setup motors
int i;
for(i = 0; i < 2; i++){
pinMode(motor_left[i], OUTPUT);
pinMode(motor_right[i], OUTPUT);


// --------------------------------------------------------------------------- Loop
void loop() {






// --------------------------------------------------------------------------- Drive

void motor_stop(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], LOW);

void drive_forward(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);

void drive_backward(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);

void turn_left(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);

void turn_right(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);


Vivek VenkatS (author)2017-07-25

This is a really informative tutorial, but I have one problem. I'm out of 100uF capacitors. Can I use a 10uF Capacitor? Or would that be a problem?

twolf8 made it! (author)2017-06-24

Made it. Using an Arduino Leonardo as MCU.

DanM5 (author)2014-09-20

Thanks for the post. I made this circuit and it worked well. The photo was taken before I found the error on only hooking the unregulated power to one pin.

AdnanA89 (author)DanM52017-05-19

i also make the same project,,, i need your help may you please help me ,,

DanM5 (author)AdnanA892017-05-19

Take a look here:

JenniferR4 (author)DanM52014-12-04


Do you have a code for that car? I have the same exact one.

DanM5 (author)JenniferR42017-03-22

Here is the code for the CoderDojo Robots that use the L293D

blacksoup (author)2017-05-04

thanks, but does this work for two l293d controlling four motors.

DenizG1 (author)2017-04-09

Hi i want to motor pin speeds with serial reading or push button pull up input so can you help me to how to do it thanks

Phoenix_8306 (author)2017-01-17

Hi Guys.

I enjoy this site very much, it gives me inspiration.

I want to build a PC Table with an Arduino where the Arduino powers a Actuator to drop and rise the screen into the Table.

I am a big gamer :)

What i am struggling with i a code and the Connections to it.

I built an H-Bridge using TIP3055 and TIP2955's

I have a external 12v power supply that i want to use for the Motor (12v-18v)

and also the Tactile push button that i want to use so that when the button is pushed, the Screen comes up out of the Table.

i am using a single button for it.

I might need to use a Pot for the speed of the Motor as it is a strong motor.

I have been searching on the net for a code as well as the Schematic, but i am failing to get any.

To be honest, i am loosing hope.

I hope someone can give me a hand.

Please Guys.

My email is

ShashankV10 (author)2017-01-15

why have we used capacitors

TechTanim (author)2016-12-14


lurt (author)2016-10-10

Can i use this circuit to control different motors (not at once), i have 9v, a 12v and a 24v. I know that the capacitors must be able to handle the voltage, but do i need capacitors with different farad ratings for each motor-setup?

Thank you for your replies!

palki gupta (author)2016-10-06

how should i control speed (increase and decrease)? i am using 1000rpm geared motors( simple motors that work as if they are 300rpm), l293d motor drivers, 12V heavy battery, hc-05 bluetooth module.

guibot (author)palki gupta2016-10-06

you should use PWM - pulse width modulation

MđS (author)2016-10-03

How i connect our arduino to l293d motor bridge please sir help me

comodore (author)2009-04-28

Hi I like your Instructables very much! Great job! I have a question that I think you may know the answer to. I need a small chip like this one that I can program and put it in a circuit so when it activates by a sensor ( in my case I want to put a light sensor (LDR))When light hits the light sensor It turns on a motor for a period of time (lets say 5 seconds). Then when the sensor finds it self in the dark it turns on the motor ( again for 5 sec) BUT IN THE opposite DIRECTION. All in All When there is lite it turns on the motor for 5 sec on one side (lets say left) when there is no light it turns the motor for 5 sec (on the oposite side, right) Do you know such a chip that will enable me to program it and make it do what I described??? Thank you! Stanislav

emmjul (author)comodore2009-05-14

You can use the same setup, simply save the states of the ldr and you can check if there was light before and have the arduino reverse the motor->

if ( pin 1 = high)
turn right
5 sec
if (pin 1 = low)
turn left
5 sec

do nothing

Hope I could help

ParasS6 (author)emmjul2016-09-09

Sir I am working with Arduino. I want to control god idle leg up and down with help of geared motor forward and reverse action please give me suggestions.

comodore (author)emmjul2009-05-14

THANK YOU SO MUCH!!! OK, so I just upload this to the Arduino? On what pins do I connect the motor, LDR, power??? I needed someone to write the code because I am a complete n00b in programing... THANK YOU! Could you please now just help me, to say, put it together, like on what pins do I connect the motor, LDR, power... Can I remove the ATMega chip and use it with out the Arduino board, connecting the components directly to the chip? Thank you!

emmjul (author)comodore2009-05-15

no you can't, it's just pseudocode so you can get an idea what you have to programm, sadly I don't own an arduino so I can't write it for you. sry

comodore (author)emmjul2009-05-22

Well... Thanks any way... Thanks, you helped me! :D

guibot (author)comodore2009-04-28

The Arduino board is fully programable, you can see more info at

ViditJ (author)guibot2016-01-19

heya m making a line follower but my motors are not working according to arduino they just run when supply is given plz do guide me

adre76 (author)ViditJ2016-01-21

Can you post the arduino code and a photo of connections so we can see ?

comodore (author)guibot2009-04-29

Yea, but I need something smaller, much much smaller like a chip...

guibot (author)comodore2009-04-29

there are arduino clones of many sizes, or can build your customized arduino only with the essencial components, I have build one for this project

check the following links:

comodore (author)guibot2009-04-30

Thank you!

Eirinn (author)comodore2009-05-02

Once you've programmed the arduino you can remove the chip, add a crystal and it can act alone with a power source - you don't always need a smaller arduino ;)

comodore (author)Eirinn2009-05-02

Great, that is good to hear... I am new in programing and electronic... :P Why do I need a crystal, actually what does a crystal do??? How should it be connected? What chip should I use? Thank you!

guibot (author)comodore2009-05-02
comodore (author)guibot2009-05-03


comodore (author)guibot2009-05-07

Thanks! x2 :D

Eirinn (author)comodore2009-05-03

I recommend the Arduino Duemillanove, it's relatively easy to use and program and the crystal (i have no idea besides this) is just to make it functional outside the board it's in. The arduino Duemillanove uses the AtMega328. ps: a "crystal" is just a component like a resister or capacitor, it's not a diamond or a ruby :P

comodore (author)Eirinn2009-05-05

I have the Arduino Duemillanove ... Are there types of crystals, if yes, which type should I use??? Are there separate chips that you can buy, without the whole board? On the chip it self hod do I know where should I hock up the sensor, power, motor, crystal... Yes, I am a n00b! ;) Thank you!

Eirinn (author)comodore2009-05-06

I will answer you honestly; i don't know. But googling goes a long way ;)

comodore (author)Eirinn2009-05-07

:P Thanks!

narnian (author)comodore2009-05-01

Any of the microcontrollers whether PIC or AVR can do this. But you will still need support components for regulating power and possibly programming interface, so yes the Arduino is a little big, but you may find you need the same components in any case.

comodore (author)narnian2009-05-02

Well, maybe, but the problem is I can't fit the Arduino into the case... I think that I I just program the chip and solder all the components... I would save much space... So should I use this chip? How do I actually program it, the chip that is? As I said, I need something a bug circuit with the programed chip that turns on the motor when it gets a signal for a defined amount of time... Thanks!

dagenius (author)comodore2009-04-30

If that is all you are looking to do, then a pickaxe 08-M coupled with the circuit in this instructable should do the trick. the cheapest 08-M that I found was about $3.00 USD.

comodore (author)dagenius2009-05-02

And how do you program them? Thanks!

dagenius (author)comodore2009-05-13

the chips have a serial in, serial out(also a in0), and a ground to share with a serial cable. They do take a little more diy to use, because the breakout boards sold on the internet are terrible, and you can make one much smaller, cheaper, and funner with a perf board, solder, pic, and various components. The pic must be programmed with a certain resistor setup that can be found all over the internet.

comodore (author)dagenius2009-05-14

Ah ok thanks! I think I am going to use an arduino, that is the arduino chip thanks!

UME1 (author)2016-01-13

Please help me !!! I just burns my 2 L293D ic's, yeah its heat up during I am controlling my Car, I am using NI -CD 8 AA 700mAH 9.6 V Battery, the positive of battery attach to the IC VSS(Pin 8) and negative of IC attach to the arduino gnd. Someone reply me please ......

chrisjlionel (author)UME12016-07-18

Add heat sinks to the ground pins as shown in the data sheet of L293DNE

floren.vanolden (author)UME12016-01-14

Wrong way round maybe? High voltage on low voltage input?

hiponiaE (author)2016-03-12

Hello about the L293D motor IC what are the other replacement for it.? I mean, there is no available stock of the said IC and im going to use it im project arduino and bluetooth car. So, is there other value of IC as replacement for it.?
Any help would be greatly appreciated, thank you.

chrisjlionel (author)hiponiaE2016-07-18

L298N is more efficient and powerful than L293DNE

sonamt4 (author)2016-05-12

sir i have one doubt ......

what is difference between l293d ic and l293den

About This Instructable




Bio: Designer & digital artist
More by guibot:Create an FPV 4WD Robotmaking wheels out of plastic bottlesClever ways of attaching components to your robot
Add instructable to: