Introduction: Easy, Reversible Motor Control for Arduino (or Any Microcontroller)

Picture of Easy, Reversible Motor Control for Arduino (or Any Microcontroller)
This project uses just three main components to provide forward and reverse control for a single motor.  You can easily interface it to an Arduino or any other microcontroller.

It's so simple - you can wire it up "free-form" without a circuit board in about 15 minutes.

All parts available at Radio Shack for under $9
Supports PWM for variable speed control
Handles up to 5 amps peak / 2.5 amps continuous (5 amps continuous with heatsink)
Controlled using just two pins - "enable" and "direction"

Requires at least 7.5 volts to operate
Relay is rated for "only" 100,000 cycles and may not be appropriate for some high vibration projects
Doesn't provide motor "braking"

The most common way to provide reversible motor control is with an H-Bridge.  A basic H-Bridge is made up of 4 transistors - but commonly end up requiring more like 10 components when you include things like flyback diodes and secondary transistors.  

I wanted something simpler for a CNC project I'm working on - so I came up with this design.  I'm fairly sure I'm not the "inventor" of this circuit - but it's not widely documented.  As far as I can tell it doesn't have a name.

I am hereby naming it the RAT Controller.  RAT being an acronym for Relay And Transistors.

Step 1: Stuff You'll Need

Picture of Stuff You'll Need

All parts are available at Radio Shack - expect to pay a bit under $9 for the main components.
The same parts are available online for under $4.

12VDC Coil DPDT Miniature PC Relay
Radio Shack Part: 275-249
If purchasing online - try searching for "OMI-SH-212D"

2 x TIP120 Darlington Transistors
Radio Shack Part: 276-2068

2 x 220 Ohm Resistors
Values do not need to be exact.

Optional: Heatsink
A TO-220 size heatsink such as Radio Shack 276-1363 will allow this motor controller to provide 5 amps continuously as opposed to just peak. You'll also need a #6 screw and nut. See the final "Notes" step for information on installing or making your own heatsink out of a pop can.

You'll also need:

Soldering Iron
And solder - any gauge is fine.

Hookup Wire
You'll need some kind of hookup wire to make connections and interface with your microcontroller.
22 Gauge Solid Core Hookup wire works well and easily fits into Arduino headers.
Available at Radio Shack - Catalog # 278-1221

Step 2: Schematic and Theory of Operation

Picture of Schematic and Theory of Operation

This circuit uses a DPDT (Double Pole Double Throw) relay to switch which direction the motor is turning.

The motor is connected to both normally closed and normally open (in reverse) sides of the relay.  This in effect reverses the wiring whenever the relay is turned on or off.

Since the microcontroller can't quite produce enough current to drive the relay - a  transistor (TIP120) is used to switch it on and off.

The "Base" of the first TIP120 is the "Direction Pin" - turning it on and off switches the direction of the motor.

A second TIP120 switches power to common on the relay.  This is used to turn the motor on and off.

The "Base" of the second TIP120 is the "Enable Pin" - turning it on causes the motor to actually run.

The enable pin may be switched on and off very quickly for PWM (pulse width modulation) speed control.

Both control pins are connected to the microcontroller via 220 Ohm resistors to limit current.

The minimum voltage to drive this circuit is determined by the "pickup" voltage of the relay.  This is listed as 9.6v - but I've found it to function properly as low as about 7.5v.

Don't worry if the schematic doesn't make total sense.  We'll go through all the connections one-by-one.

Step 3: Bridge NO and NC Pins (Part 1)

Picture of Bridge NO and NC Pins (Part 1)

Position the relay in front of you as shown in the picture.

Use a piece of hookup wire and your soldering iron to connect the pins as shown.

This connection bridges one of the Normally Open (NO) relay pins to one of the Normally Closed (NC) relay pins.

Step 4: Bridge NO and NC Pins (Part 2)

Picture of Bridge NO and NC Pins (Part 2)

Again - use a piece of hookup wire and your soldering iron to connect the pins shown.

This connection bridges the other Normally Open (NO) and Normally Closed (NC) relay pins.

Step 5: Connect Coil Pin to Common Pin

Picture of Connect Coil Pin to Common Pin

One last time - use a piece of hookup wire and your soldering iron to connect the pins shown.

This connects one of the relay's Coil pins to one of its Common pins.  Both of these pins will later be provided with positive voltage.

Step 6: Connect TIP120 Collector to Relay Coil Pin

Picture of Connect TIP120 Collector to Relay Coil Pin

Solder the middle pin of one of the TIP120s to the relay pin on your lower right (as pictured).

This connects the TIP120 Collector pin to the relay's other Coil pin.

Step 7: Nudge TIP120 Into Position

Picture of Nudge TIP120 Into Position

Carefully push the TIP120 towards your left and against the relay as shown.

This isn't just cosmetic - the TIP120 needs to be in this position for a connection we'll make later.

Step 8: Connect Second TIP120 Collector to Relay Common

Picture of Connect Second TIP120 Collector to Relay Common

Solder the middle pin of the second TIP120 to the bottom pin second from the left on the relay (as pictured).

This connects the second TIP120 Collector pin to one of the relay's Common pins.

Step 9: Connect TIP120 Emitters

Picture of Connect TIP120 Emitters

Push the second TIP120 up against the relay's case.

Bend the left-most pin of each TIP120 towards each other until they touch.

Solder the pins together as pictured.

This connects the Emitter pins of the two TIP120 transistors.

Step 10: Connect Resistors

Picture of Connect Resistors

Trim the leads of two 220 Ohm resistors to about 1/4 inch using scissors.

Solder a resistor to the end of the right-most pin of each TIP120 as pictured.

These resistors are connected to the Base of the transistors.  They limit current flow between the transistors and your microcontroller to safe levels.

Step 11: Review Connections

Picture of Review Connections

Congratulations!  You've completed the basic wiring - let's review how to hook things up.

+ Power
Connect this pin to your power source of 7.5v or higher.

This pin needs to be connected to both ground of your power supply -and- ground on your microcontroller.

Connect this pin to a pin on your microcontroller.  Turning on this pin turns on the motor.
If you use a microcontroller pin with PWM - you can use it for variable speed control.

Connect this pin to a pin on your microcontroller. Turning on or off this pin switches motor direction.

Motor 1 and Motor 2
These pins connect to your motor leads.

Step 12: Hook It Up!

Picture of Hook It Up!

Connect all leads as listed in the prior step using hookup wire and your soldering iron.

Be sure to connect the GND pin to Ground on both your power source, and your microcontroller.

If you're using an Arduino - connect the Direction Pin to Arduino Pin 8 and the Enable Pin to Arduino Pin 9.

Step 13: Upload the Code and Test

Picture of Upload the Code and Test

Place the code below in an Arduino sketch - and upload it.

If you're not using an Arduino - review the code below to figure out what's going on.  It's not rocket science.

You should have a working motor controller!

//pin 8 = direction
//pin 9 = enable

void setup() {
pinMode(8, OUTPUT); //set direction pin as output
pinMode(9, OUTPUT); //set enable pin as output

void loop() {

//start off going forward at 50% throttle
digitalWrite(8, HIGH); //forward
analogWrite(9,128); //50% PWM

//full speed ahead!
digitalWrite(9, HIGH); //full speed

//and stop for a while
digitalWrite(9, LOW); //turn enable pin off

//now lets go backwards
digitalWrite(8, LOW); //backward
analogWrite(9,128); //50% PWM

//and stop for a while
digitalWrite(9, LOW); //turn enable pin off

Step 14: Notes

Picture of Notes

If you're having problems with the controller refusing to reverse - it may be that your input voltage is too low.

The relay's coil seems to dictate the maximum voltage this circuit can handle.   It's rated at 130% of nominal - or 15.6v.

Unlike many commercial motor drivers - this driver does not have any "protection" - so if you abuse it too much - it will fail.  Fortunately - the component most likely to burn out is the transistor with the "Enable" pin - so you're only out a $1.50.

It should be possible to build a version of this driver that supports lower voltages by swapping out the relay with one having a lower "pickup" voltage.  I chose the one featured in this project since Radio Shack stocked it.

This project uses TIP120 "Darlington" transistors. These transistors are actually two transistors chained together into one. This gives them much higher "gain" - meaning they can use a very small current to switch a much larger current.  A TIP120 on its own provides a super-simple way to do single-direction motor control.

The TIP120 is rated at 5 amps - but will overheat without a heatsink if run this hard continuously.  I've verified the Radio Shack 276-1363 heatsink can be installed without re-soldering everything (you may need to bend stuff a little).  The heatsink should be installed on the transistor with the "Enable" pin using a #6 bolt and nut (screw it on tight!).

You can alternately make your own heatsink out of a piece of aluminum can.  Just cut a 1"x1" piece of the can using scissors - bend up the sides a little, and drill an 5/32" hole to mount it.  This may not work as well as a proper heatsink - but will definitely help.

Swapping out both the TIP120 and relay with higher-rated parts (readily available online) should let you build a much beefier version of this motor control fairly cheaply.

Have fun!


16jlin (author)2017-11-01

excellent instruction. Question - how does the circuit work if I don't need to turn motor on? In my scenario i am connecting to a stall motor (tortoise point motor). Can I do without the second TIP 120?

ArpitaM3 (author)2016-11-14

Hi, I made the connections all same as this but, my motor does not turn. Also, when I tried checking the voltage at all pins of relay it is around 12V. Please help!

nothinglabs (author)ArpitaM32016-11-18

Maybe check your connections again? Did you ever plug anything in backwards? Does your power supply provide enough current to turn the motor?

ArpitaM3 (author)nothinglabs2016-11-28

I have checked my connections and also motor works fine when connected directly to power supply.

What do you mean by plugging anything backwards?

unboxed213 (author)2016-08-08

i used this same motor 2 pin method with just an arduino micro and a dc motor

in the d8 and d9 pin slots it works going orward but going backwards it just goes really slow forward

nothinglabs (author)unboxed2132016-08-26

Sorry for slow response...

Not sure why it would be doing that... wondering if maybe the power source is experiencing some voltage sag when the relay is engaged?

also - some motors are "timed" so they spin faster one direction than the other...


RishikeshC (author)2016-05-09

a rookie here so im sorry if the following question is stupid but if i replace the darlingtons with MOSFETS will it still do the trick?

danep93 (author)2016-04-27

Hey Rich, is there any way to add some code and a switch button to brake the motor? I like the design a lot but I definitely don't want the motor to be continuously running

RishikeshC (author)danep932016-05-09

i guess you could modify the code a bit

like when the button is pressed the enable pin is switched off and there is no delay in it

something like:





nothinglabs (author)danep932016-04-28

Existing setup already allows for on/off control via the "enable" pin.

If you're referring to active braking by shorting the motor.leads together - don't think there's easy way to do that.

Good luck!

aredwan (author)2016-02-02

very helpful!

i made it with MOSFETs

JeffJ21 (author)2015-10-27

i made that circuit for running 12VDC car seat motor but one transistor (i.e. Enable one just keep burning. What should be possible solution to avoid that? Moreover, i did trying using heat sink and thermal paste but did not work the whole appratus just run for hardly 2 or 3 minutes and then transistor just go bad. Help needed

nothinglabs (author)JeffJ212015-10-31

It sounds like you're just drawing too much current for the tip120 datlington.

You could try swapping the tip120 with a MJ11032GG (about $10 online). Way more current handling.

That said - if you're going down that path may make more sense to look at other options (pololu is a good website for motor drivers).

Good luck!

goldenshuttle (author)2015-10-12

Great post.indeed simple and useful..can utilize those relays who are depressed from unemployment...thumbs up to you.

heyitsalan (author)2015-05-11

I'm considering using this circuit for a project at my internship. The caveat is I'm using a 12V 10A power supply as my motor draws a fair bit of current. I've already sourced a 12V 10A relay but as far as transistors go, I believe I need to go with 2 MOSFETs in order to handle the larger current. Would these work in place of the TIP120s? I'm also assuming the MOSFETs do not have built in flywheel diodes, and so I'm wanting to know where those would fit into the circuit.

thanks for any help and great instructable btw!

donald.bejleri (author)2015-05-04

What motor do you use? I like the one in the video, would like to use the same model! Thanks!

actually have no idea of model (was many years ago I got it).

some places to look for gear motors:

PritpalM1 (author)2015-05-06

i finally managed to get the device to work.

AndrewS12 made it! (author)2015-04-26

Great instructable. I used 3 of them to control a robot for a local science fair yesterday and the circuits worked great. The robot worked continuously for 4.5 hours without fail. I am planning on using a similar circuit for a summer camp. I was wondering about the value of diodes to limit surge voltage from the inductors? Anyone have any thoughts?

nothinglabs (author)AndrewS122015-04-29

Glad you like the instructable!

The tip120 has a built-in snubber diode for some level of back EMF protection:

I've found them adequate for most of my needs. Other darlingtons I've used have generally had adequate built-in EMF suppression for the kind of loads they were designed for (not saying you shouldn't add another snubber diode - not sure what I'd recommend though).

Have fun!


deuchar (author)2015-03-08

Hey guys I have been able to control the motor speed and halt. But I am not able to change the direction I am using this relay

Kindly help.

bennetta (author)2015-01-05

hey, i hav built a circuit to control 3 dc motors using icl293d , the operations include forward, reverse and speed control. the code works fine when motors are connected separately, but when powered together, it just stops in between and the resets the program.please help.

nothinglabs (author)bennetta2015-01-10

It might sound obvious - but I'd make sure you don't have any shorts.

If you're trying to run all the motors at once - it might be overtaxing your power supply and causing a brown-out.

Good luck!


427hotrod (author)2015-01-05

im trying to make a east speed control for a small dc motor i dont want to use a h brige simpllifying the design im trying to use a volume control but seems to not work anything i should try using for a control or is it fine i dont want to use an h bride thats the thing

JasonK6 (author)2014-12-17

I have built the exact circuit you have, same parts. I wired it up and hooked it up to a motor. The motor immediately turned on as the 12v clicked the relay, it seems like the arduino is doing nothing to the circuit. Volt meter shows the arduino sending signal but the relay isn't switching back. I think the enable transistor is shot, unknown. Thoughts?

nothinglabs (author)JasonK62014-12-19

I would triple-check all wiring - and verify you're using the same model of relay.

It's possible the enable transistor is shot - but the darlingtons are pretty sturdy...

Nazih (author)2014-12-10

Hi, I am planning to build one for a moving santa going up and down on a rope using a 12 volt DC electric motor, could the reverse action of the motor be set to a certain timings (say 2 min) after which the motor will automatically reverse the rotation, for un limited period, until it is shut off? Regards, Nazih

nothinglabs (author)Nazih2014-12-10

as long as you use a microcontroller (like arduino) - you can do pretty much whatever you want.

good luck!

nothinglabs (author)2014-11-21

So - not totally following what you're trying to do. I think if you're using a i-o-ii type switch with two poles (probably 6-pins total) - that might be enough to do forward / reverse / off on a motor..

dan.t.carter.92 (author)2014-11-18


I am not too clued up on this sort of thing but I will be making one of these to control the opening and closing of a drawer using a threaded rod and nut, although, I will only be using a 'I-O-II' switch. I assume I would replace that piece of kit for the 'I-O-II' switch? And I assume that 'I' will go forward 'O' will kill it and 'II' will reverse if I use this same setup?


jason531 (author)2014-10-08

Thanks for this. I was looking for an inexpensive H-bridge I could make from locally-available parts.

I am new to this type of thing, so forgive me if this is a naive question. If you were only interested in on/off and not PWM, couldn't you use the "enable" pin to drive the coil on an SPST relay which would then connect ground the common pin on the DPDT relay? That way you would only be driving the coils (your DPDT only uses 60ma) and would only be limited by the max current of the relays themselves. The TIP120s should be able to handle just about any size relay (RS sells a 10A DPDT with a coil rating of only 130mA).

I am asking because I want to use an old cordless drill and I've read that those things can pull over 100A! Thanks again for posting this guide.

nothinglabs (author)jason5312014-10-20

Sorry for slow response.

Yes - I suspect you can add an additional relay after the "enable" TIP120 - and then use it to drive as large a load as it can handle.

Sounds like a good idea if you're not interested in PWM. You might even be able to do very slow / loud PWM - not sure how long that would last though...

Have fun!


michael.a.wiseman1 (author)2014-08-15

What would you need to add or do to make the motor go faster forwards and backwards and have a manual mode and auto - mode for 30 seconds involved into the circuit?

gcarter5 (author)2014-06-07

This is absolutely brilliant Thanks a bunch for awesome instructions. its exactly what i was looking for as h bridges keep over heating and cooking my BD135 NPN transistors. I owe you a beer. Cheers

nothinglabs (author)gcarter52014-06-14

Happy to be of service!

atai07 (author)2014-03-12

hello .. I have tried your circuit but the motor only moves in one direction only .. the delay is still there ... but I still hear the sound Click on the relay ..

so where is my mistake ... can you explain

I use tip 122 ..

relay as you use

batery 12 v 1.2 AH

plz help me ...


nothinglabs (author)atai072014-03-12

If the relay is engaging - but the motor direction isn't changing - I would triple-check how you have the relay wired. (assuming you're using the same kind of relay as described)

Good luck!


brij_malhotra (author)2014-03-11

Can I connect two motors to the pins of relay instead of one for my project

or I need to make two similar circuits?

and, any other 6v relay should work fine, should nt it?

erich.haubrich (author)2014-02-15

It worked pretty well until I burned it up. :)

ArthurCornelis (author)2014-01-25

Hi, i stumbled uppon a problem. I can hear my relay switch but when i hook up a 6/9v dc motor to it my motor doesn't turn. I'm using 7.4v.

The relay is only used to switch the direction of the motor - as opposed to actually toggling the power.

The tip120 connected to the "enable" pin is responsible for toggling the actual power - so I'd start troubleshooting there.

Good luck!


zhungu (author)2013-12-14

Hello again. is there a way it can be modified to have "brake"?

nothinglabs (author)zhungu2013-12-15


I think typically motor controllers "brake" by shorting the motor leads. I don't think that's possible with this setup.

However - you could try quickly toggling the direction pin (maybe 20hz - 40hz) - and then doing some level of PWM on the enable pin.

Can't say if this will work - but it might. It will certainly make some noise though - and might not be very "nice" to the various components...

zhungu (author)2013-11-16

Hie. would this relay work as well? How do i know which ones are the normally open, normally closed pins and so on? Thanks

nothinglabs (author)zhungu2013-11-18

I believe that relay would work assuming you provide the needed voltage.

I would suspect there is some indication on what pins do what on the relay itself. Otherwise - I might just experiment using a multimeter.

crob09 (author)2013-10-15

Hope you don't mind the question but I'm wondering how this circuit could be used to control a high power device, it looks like the 12V-power charges the relay coil and drives the motor, I maybe wrong but is there a way to connect another power source to drive say a 36VDC motor?
Thanks for any help,

nothinglabs (author)crob092013-10-16

Should be able to - just find a DPDT relay and "drive" darlington of the values you need.

The darlington that triggers the relay can probably stay a tip 120.

On this page I mention I higher power darlington option:

(the solid state relay on that page might also be of interest)


crob09 (author)nothinglabs2013-10-16

That link takes me to an awesome project thanks!!
Maybe I'm confused about the Relay, I notice they have two values one for the coil (I think) and the other for the max load, will the Max-load value work for the coil too, for example below the relay is rated at DC5V 28VDC?
Sorry I really don't see how I connect a higher voltage to this, My relays are "JQC-3F(T73) DC 5V 5PIN 250VAC 28VDC Power Relay"
I suppose this won't work also because of them being five pin opposed to six?

nothinglabs (author)crob092013-10-18

For this project you'll want DPDT relays - which I don't think those are.

Good summary on what this means here:

Relays are commonly rated at a voltage / current required to engage (you can usually go somewhat higher or lower) - and the maximum voltage / current it can switch (often different for AC and DC).


crob09 (author)nothinglabs2013-10-24

Cool I've ordered some of the DPDT relays and the proper voltage.
Thank you for the summary link, you're right it has tones of good information.
Also thank you for the reply to my question and great job on the Tutorial.
Is it alright if I post something like this on my MOSFET page on

About This Instructable




Bio: Hi, I'm Rich Olson ( I sell cloud chambers for viewing radiation, make robots and dev software. If you need something prototyped - I ... More »
More by nothinglabs:Parametric 3d Printed Death Star Speakers3D Printed Bike Shifter (friction)2-Layer Circuit Boards Using Laser Cutter / Chemical Etching
Add instructable to: