Introduction: $1 Motor Driver Circuit for Arduino

Picture of $1 Motor Driver Circuit for Arduino

The story of this motor shield is that I wanted to make a robot for my multifunctional brainwave controlled system and I decided to share this with you. It's a very simple circuit I used the L293D IC that is a dual bridge motor driver IC. I also added an output for a servo motor. Finally this circuit was able to control 2 DC motors or 1 stepper motor and a servo motor.

So let's get started!

Step 1: Gathering the Parts

Picture of Gathering the Parts

For this project you'll need only a few parts:

  • 2 Screw Terminals
  • L293D IC
  • 3 Header Pin
  • 9 Header Pin (90 degrees)
  • 1k Resistor
  • Red LED
  • Wires
  • A PCB Board

Tools:

  • Soldering Iron
  • Solder
  • Wire Stripper/Cutter

Step 2: Soldering

Picture of Soldering

As you can see I used a LinkIt ONE but you can use an Arduino UNO as microcontroller. And you can connect the pins to any I/O pin of the microcontroller. First insert the parts in the holes of the PCB then solder to it.

Step 3: Wiring Up

Picture of Wiring Up

I used some copper wires and following the schematic connected the pins of the IC to the header pins. Doesn't matter that which pin goes to which header pin, just remember that were did you connected them. The LED is connected in series with the resistor and in paralell with the 5v VCC.

Step 4: Powering Up

Picture of Powering Up

I simply connected a 5 volt power source to the test the circuit.

Step 5: Connect the Motors

Picture of Connect the Motors

Connect the motors to the motor driver circuit. Then the digital pins to the header pins. Example if D6 is high the motor starts spinning because the IC pulls up the output pin to HIGH. So if the selected pin is HIGH the motor spins to the programmed direction.

In my Case:

  • D11---> Motor 1 Right
  • D10---> Motor 1 Left
  • D6---> Motor 2 Right
  • D5---> Motor 2 Left

Step 6: The Code

Copy this Code in your IDE then upload as you see every pin controls a direction of the motor.

#include <Servo.h>
Servo MyServo
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT)
  MyServo.attach(3); //connect the servo to pin D3
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(11, HIGH);
  delay(2000);
  digitalWrite(11, LOW);
  digitalWrite(10, HIGH);
  delay(2000);
  digitalWrite(10, LOW);
  digitalWrite(5, HIGH);
  delay(2000);
  digitalWrite(5, LOW);
  digitalWrite(6, HIGH);
  delay(2000);
  digitalWrite(6, LOW);
  MyServo.write(170);
  delay(1000);
  MyServo.write(0);
}

Step 7: Thanks for Watching!

Comments

kohellus made it! (author)2016-03-25

Made it. hopefully works too :) Wasnt sure how to connect the servo. one motor is out of the picture when the servo is in use so maybe power from motor and third cable for data to the header pins? Iam not good at this. But great instructable, thanks alot!

bardi (author)2016-02-03

It's a wery good Idea! Can You write about phone controll, pl?!

Imetomi (author)bardi2016-02-27

Sorry for the late reply, look at my BB-8 instructable...

JavierV26 (author)2016-02-10

it's not opto isolated so it could potentially damage other compontents, but it still super useful good job.

Lanvi (author)2016-02-01

Oh my god I love your little helper hands, which are glued to your desk :'D

Those are so adorable and I'm SO going to copy that idea, to make little helper-boards for electronics with my students x)

Imetomi (author)Lanvi2016-02-02

Thank you and you're welcome!

RaymondR6 (author)2016-02-01

Since you didn't specify the wiring for the pin header, I strongly suggest keeping the power pins much apart. In the photos, the +5 VDC clip is too close to the ground clip!

grayl (author)2016-01-31

Probably the most important picture is missing - that of the underside of the board.

jimvandamme (author)grayl2016-01-31

It's a bare board, with no copper traces. You have to wire it according to the schematic. Which is faster than making a board this simple.

grayl (author)jimvandamme2016-01-31

thanks, Jim

alonsomaria (author)2016-01-31

Hello: I am interested in the working with brain waves and read "multifunctional brainwave controlled system" in the introduction of the instructable, so this attracted my interest. Will you please indicate me where can I get more info on the subject?

Best regards

RomanMQ (author)2016-01-29

Everytime you work with a huge load, for example an electric motor, you should add any type of protection (isolation) between the control and the output stage, such an optocoupler, to avoid risk of damaging the controller. It´s just my recommendation :)

Where do you suggest the optocoupler should be placed?

The optocoupler should receive de control signal from your microcontroller and then its output should be connected to the inputs of the L293D. But, remember that you´ll need two DC sources, one for the motor and another for the Arduino or microcontroller your using, both grounds should be coupled.

Imetomi (author)RomanMQ2016-01-31

Thank you, but keep in mind that Arduino users who want to make robots aren't using more than 12 volts so the octocoupler isn't neccesary. Look at the Adafruit Motor Shield, it's based on this IC. The L293D has build in protection diodes. :)

RexS1 (author)RomanMQ2016-01-30

Optocouplers are useful when controlling mains voltages to avoid any risk of electrocution or mains voltages appearing on the low-voltage control circuitry. When driving low-voltage DC motors, they don't serve much purpose.

However, when driving any inductive load, the output stage needs to have a diode that 'clamps' the output, preventing the back-emf of the inductor from rising above the positive rail and potentially damaging the output transistors. In the L293D (but not the L293), each output is protected by an internal clamping diode. The outputs are rated to 600mA continuous, 1200mA peak. If you use motors that keep within those limits, there's no real risk of damage. The TI datasheet for L293/L293D is available at:

http://www.ti.com/lit/ds/symlink/l293.pdf

Imetomi (author)RexS12016-01-31

Thanks for the reply! I totally agree with you.

ngwpower (author)2016-01-31

Will try this for ho train, as a door opener for the main shop.

Question is do we add the optocoupler or not. If so please revise the schematic. Just getting into this new age of micro electronics.

Thanks

Imetomi (author)ngwpower2016-01-31

This IC doesn't need an optocoupler. That's why I use this L293D.

kodfarki (author)2016-01-31

is it possible to make speed control?

Imetomi (author)kodfarki2016-01-31

Yes, you just have to use "analogWrite" instead of "digitalWrite".

diy_bloke (author)2016-01-28

great, what is a seerco motor?

Omnivent (author)diy_bloke2016-01-28

Probably a typo for the servo motor mentioned one line higher.

diy_bloke (author)Omnivent2016-01-31

Tnx. I just wanted to make sure I had not missed out on some specific type of motor, Especially since there seems to be a brand with that name

Imetomi (author)diy_bloke2016-01-30

Sorry was a typing error.

diy_bloke (author)Imetomi2016-01-31

no problem. I just wanted to make sure that I wasnt aware of some type of special motor

stewartdunn (author)2016-01-29

Any chance you can add servo code for testing

Imetomi (author)stewartdunn2016-01-30

I added.

TheFlorifant (author)2016-01-28

yes, awesome. A few weeks ago I ordered some l293d for a cnc plotter, this came just in time!

About This Instructable

37,408views

772favorites

License:

Bio: Hi, I'm Tamas (Thomas), a 17 years old Hungarian guy. My hobby started more than 10 years ago. I learn electronics, physics, programming, IoT ... More »
More by Imetomi:DIY Cheap VR FPV System for Drones, Planes, CarsUltimate Intelligent Fully Automatic Drone Robot (w/ RPi, Arduino) Jedi Force Gestures Based Home Automation (with Smartwatch)
Add instructable to: