You are on page 1of 1

Controlling Motors

(H-Bridges & L293D)

The Theory & Code


Controlling Motors
While turning a motor on and off requires only one switch (or transistor) controlling the direction is
deceptively difficult. It requires no fewer than four switches (or transistors) arranged in a clever way.
H-Bridges
These four switches (or transistors) are arranged in a shape that resembles an 'H' and thus called an
H-Bridge. Each side of the motor has two transistors, one is responsible for pushing that side HIGH
the other for pulling it LOW. When one side is pulled HIGH and the other LOW the motor will spin in
one direction. When this is reversed (the first side LOW and the latter HIGH) it will spin the opposite
way.
DC Motor Example
Confused? that's alright it all starts making sense with an example. Cut out the breadboard layout
sheet below and download the example code from http://tinyurl.com/qcpah9 and play around.
Stepper Motor Example (for use with 4, 5,6 & 8 wire motors)
The Arduino IDE has an included library for controlling stepper motors. To test it out with this setup,
plug the stepper motor in with coil A across OUT 1 & 2, and coil B across OUT 3 & 4. Then download
example code from http://tinyurl.com/nyylun and play around.

.: Arduino IDE Stepper Library Reference http://tinyurl.com/kvquny :.


.: L293D Datasheet http://tinyurl.com/l37lw9 :.

The Pin-out The Limits


1,2EN-1 16-Vcc1(logic) .:Current Per Channel:.
1IN-2 15-4IN
1OUT-3 14-4OUT
600 mA
L293D

gnd-4 13-gnd (max peak 1.2A)


gnd-5 12-gnd (under heavy loads the chip will get quite
2OUT-6 11-3OUT
hot and may need additional heat-sinking.
2IN-7 10-3IN
(supply)Vcc2-8 9-3,4EN It also has thermal protection so will
shutdown before breaking)

The Circuit The Layout Sheet


There is a half moon to A B C ifDusing F Gto
E 5 volts H Gnd
I J
cutout, this goes at the top supply
voltage 1 to 5v 1
(must share 2
common ground)
IC 2
3 L293D 3
4 1,2EN-1 16-Vcc1(logic)4
to pin 9 5 1IN-2 15-4IN 5to pin 5
to pin 2 6 1OUT-3 14-4OUT 6
L293D

7 gnd-4 13-gnd 7
8 gnd-5 12-gnd 8
9 2OUT-6 11-3OUT 9
to pin 310 2IN-7 10-3IN to
10 pin 4
11(supply)Vcc2-8 9-3,4EN to
11 pin 10
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
coil B coil A
22 22
23 Stepper Motor 23
24 24
25 CIRC-22
25
26 Controlling26
Motors
27 (L293D)
27
28 28
29 29
30 30

A B C D E F G H I J

.: Instructions: print out, cut out, get making :.


.: for more details visit: http://tinyurl.com/nsuwln :.

You might also like