Control your motors with L293D and Arduino

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
 
Remove these adsRemove these ads by Signing Up
 

Step 1Basic implementation

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:
« Previous StepDownload PDFView All StepsNext Step »
47 comments
1-40 of 47next »
Apr 28, 2009. 11:07 PMticapix says:
Thanks for the article :) Can you explain or give to link which explain why you put capacitors ? (and why this way ?) Diodes aren't good ?
Apr 28, 2009. 11:45 PMWyle_E says:
The capacitors from the motor leads to ground absorb noise generated by the motors. Motors are notorious for generating spikes that interfere with nearby logic and sensor circuits. The big capacitor across the battery smooths the supply voltage, keeping the internal resistance of the battery from dragging the bus voltage down when the current into the circuit suddenly increases (like when you start a motor). The parallel pair of capacitors from +5V to ground filter the logic-circuit supply. The big electrolytic capacitor soaks up low-frequency trash, but isn't so good at handling high-frequency noise, like that generated by fast-switching logic. The .1 microfarad capacitor is a ceramic or polyester type that handles the hign frequencies.
Jan 21, 2012. 3:18 AMbooze.net says:
This post has been a great help to me. I had numerous problems affecting my logic as I hadn't implement the ceramic capacitors detailed in your post. I was tearing my hair out and temporarily abandoned my project. Thank you very much.

Paul
Apr 29, 2009. 12:09 AMticapix says:
thanks Wyle_E :)
Apr 7, 2011. 9:08 AMshanakaplus says:
um looking for elevator avr program. Do you have example program ?
May 15, 2010. 4:33 PMmoose4987 says:
 so, say i were to use a motor to turn a solar panel... if i used the voltage from the solar panels which vary from 6-9 volts to power the arduino, could i also use that unregulated voltage to power the L293? 
Mar 2, 2010. 4:06 PMchris27 says:
Hey, sorry to bump an old thread, but I'm thinking of using four PICAXE 08-M chips as slaves for DC motor control via PWM, routed through a L293D (four mono-directional motors).  The only example I've seen of this kind of setup (http://www.phanderson.com/picaxe/pwm_stamp.html) seems to suggest that in order to change the duty cycle of the PWM out, you have to pull pin 4 low, then pulse a certain number of times in 100ms, then pull pin 4 high again.  Is that true?  If so, it's only possible to change the motor speed a maximum of 10 times per second - which isn't very useful when making minute adjustments to respond to gyro stabilisation.  Anyone know of a better way to achieve this?

Cheers
Jan 13, 2010. 1:43 AMfelixk says:

Great Job! :)

I noticed that in the final breadboard (Page 3 of the downloadable pdf), you have included servo control and a couple of extra capacitors that are not in the system diagram. Any chance of a complete schematic of this circuit?

Thanks

Jun 8, 2009. 9:36 PMmani.atico says:
Hi,
I'm new to electronics (follow instructions level) and this instructable helped me a lot on bringing two motors to life with my arduino.

I have a basic question: is it better to use the 5V arduino output or a regulated current from the ext source (as shown on this instructable) for the L293D logic input?

Thank you
Aug 20, 2009. 10:46 AMicecreamterror says:
ext source, always better with the Arduino.
Apr 28, 2009. 3:44 PMcomodore says:
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
May 14, 2009. 4:16 AMemmjul says:
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
}

else
{
do nothing
}

Hope I could help
May 14, 2009. 11:17 AMcomodore says:
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!
May 15, 2009. 7:52 AMemmjul says:
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
May 22, 2009. 2:11 AMcomodore says:
Well... Thanks any way... Thanks, you helped me! :D
Apr 30, 2009. 5:08 PMdagenius says:
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.
May 2, 2009. 9:36 AMcomodore says:
And how do you program them? Thanks!
May 13, 2009. 5:49 PMdagenius says:
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.
May 14, 2009. 11:10 AMcomodore says:
Ah ok thanks! I think I am going to use an arduino, that is the arduino chip thanks!
Apr 29, 2009. 8:00 AMcomodore says:
Yea, but I need something smaller, much much smaller like a chip...
May 1, 2009. 5:46 PMnarnian says:
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.
May 2, 2009. 3:30 PMcomodore says:
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 small..like a bug circuit with the programed chip that turns on the motor when it gets a signal for a defined amount of time... Thanks!
Apr 30, 2009. 5:12 AMcomodore says:
Thank you!
May 2, 2009. 1:29 AMEirinn says:
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 ;)
May 2, 2009. 3:32 PMcomodore says:
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!
May 3, 2009. 1:54 AMEirinn says:
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
May 5, 2009. 1:04 PMcomodore says:
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!
May 6, 2009. 8:20 AMEirinn says:
I will answer you honestly; i don't know. But googling goes a long way ;)
May 7, 2009. 1:22 AMcomodore says:
:P Thanks!
May 3, 2009. 4:03 PMcomodore says:
Thanks!
May 7, 2009. 3:22 AMcomodore says:
Thanks! x2 :D
Apr 29, 2009. 12:47 PMlordofthedonuts says:
Nice to see some folks from LMR on insturctables, keep up the good work!
Apr 28, 2009. 11:18 AMkurtbadelt says:
Hi. i have one like this but i used diodes instead of capacitors. whats the diference? should i migrate to caps?
Apr 27, 2009. 6:29 PMe-Killer says:
what I have to do if i need PWM support? just using pwm outputs from arduino to inputs on this schematic?
1-40 of 47next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
14
Followers
4
Author:guibot
Designer & digital artist