3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Easy, Reversible Motor Control for Arduino (or any Microcontroller)

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.


Features:
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"

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

Step 1Stuff You'll Need

Stuff You\
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


« Previous StepDownload PDFView All StepsNext Step »
54 comments
1-40 of 54next »
Apr 15, 2012. 7:20 PMcompgeek97 says:
does it matter what relay is used as long as it's 12v 5a? i found 2 OMRON MY2NJ on ebay for cheaper than the ones used in this instructable. I'm a kid with no job so I kinda need to cut all the corners I can :D
Aug 25, 2011. 2:31 PMDNMEBOY says:
I made this and it seems to be working correctly but my motor does not go backwards. Any ideas?
Dec 17, 2011. 2:09 PMstupidloginthing says:
funny. I'm using a 10 volt battery and using this circuit for a stepper motor from a drill intended for 7.2 V. It won't go backwards either. (I set the PWM power control to half (128) so that it's not too hard on the motor.)

I get the feeling something is fundamentally wrong because no power comes through to the motor when it's supposed to be running in reverse.

any ideas?
Sep 3, 2008. 4:13 PMstupidloginthing says:
yeah its not a stepper motor it just behaves strangely. I think that's likely because we had an AC-DC power source before that we set at 12V and it worked fine then. the battery was producing 10.8V, which wasn't quite enough to reverse it, then later it didn't make a sound and wouldn't reverse (as battery drained).

anyways I ordered a motor controller because I'll need to use servos too. this was a good experiment and got us an A on our class project, so thank you.
Aug 25, 2011. 3:02 PMDNMEBOY says:
Nevermind, I was using a 7.4v lipo to power this project, I had the thought that the voltage may not be enough so I connect a 12v Lead Acid battery and it works exactly as it should. So if anyone else runs into the same problem chances are its your input voltage being to low. I wish I still had some 3s 11.1v lipos. The lead acid battery is just BIG.
Sep 6, 2011. 2:12 PMDNMEBOY says:
I disconnected everything from my arduino after running a motor with this and now windows doesnt even see my arduino uno, nothing in device manager, any ideas? im pretty bummed since i just ordered that motor sheild.
Sep 8, 2011. 11:08 AMDNMEBOY says:
It seems that the 8u2 on my board has died. It's the only thing I can think of. It makes sense as the 8u2 is in charge is USB/serial communication. Which isn't working yet the arduino still runs your sketch. Your project isn't to blame I'm sure. Just that I was messing around with it when my arduino stopped working. I had the USB plugged in while running the motor. I could hear the arduino connecting and disconnecting from windows. Not sure what happened. The project was powered with a 12v lead acid battery. Positive to your motor controller and ground to the ground on the arduino as well as the ground from the motor controller to the arduino. My guess is that something was connected wrong but no different than the first time I did this project.

I only asked you because you seem to know more than me about this stuff and I was desperately trying to find the problem. The seller has agreed to ship me a new arduino provided I return the dead one. Going to be a long wait from hong kong.
Sep 9, 2011. 5:09 AMDNMEBOY says:
According to what I've learned if the led on pin 13 blinks on reset the bootloader is fine. The arduino still runs your sketch. Maybe if my replacement fails I'll purchase an arduino that's not a clone. I've got 3 kids so money is tight. If I can get a clone for 20 bucks on eBay with free shipping that's a great deal. I've also always been told that the only thing worth buying cheap is beer. So maybe a quality arduino would be worth the extra money.
Sep 6, 2011. 11:44 AMDNMEBOY says:
I found a 5v relay at radioshack but honestly I would have no clue how to wire it up and make it work like the one you made.

I went ahead and ordered a motor controller based on the L293D from ebay. Just waiting for it to arrive from hong kong...

Im planning on building an autonomous vehicle that uses skidstearing. So basically like a little tank. Ive got alot to learn. Right now im pretty much just finding tutorials like this and copy/pasting code. Ive yet to come up with anything on my own.
Dec 14, 2011. 10:23 AMEternal_Tristan says:
You should be able to swap a 2n2222 for the giant TIP-120 connected to the relay coil. That will save you a couple bucks.
Aug 31, 2011. 11:31 PMcShellPro says:
Hi NothingLabs,
having read your Instructables, I'm wondering
why you use a relay to control a motor?

You could build a simple H-Bridge
and drive the MOSFETs with transistors.

Please have a look at this link:

http://www.instructables.com/id/H-Bridge-on-a-Breadboard/

Ciao Frank
Sep 1, 2011. 12:40 AMcShellPro says:
For an H-bridge you just need two transistors, four MOSFETS
and of course resistors or go straight for
an H-Bridge such as SN754410. Parts are readily available.
Apr 13, 2011. 12:53 PMSwishercutter says:
Is that really your soldering iron tip? I think you need a new one. Once you have the new one do 4 things to preserve your tinning.

1.) Before you power up (every time) make a coil of solder on the tip so that it melts as the iron warms up.
2) Always add solder to the tip before setting the iron in the holder. Some people say keep the tip clean but that only applies to the dross (blackish metallic stuff that builds on the tip that doesn't melt), it is best to always have solder on your tip.
3) Add a large blob of solder to the tip as you turn the iron off so that there is a blob on it while its being stored.
4) Never...I will repeat NEVER use your soldering iron for anything except solder.
Air exposure while heated is what damages the tip mainly. Your solder joints will flow better and easier with a maintained tip.

These are the things I was taught in industry by 30 year solderers.
Jul 23, 2011. 7:58 AMptacnik says:
I Went trough the hassle of getting IPC certificates once, This transcripts from the DVD's Exist !! FREE !!! here is one for Soldering Iron Tip Care and you can get the certificate for FREE !!!!  the good thing is that you can try as many times as you want, you will notice that Tin can Disolve the Iron plating, and the sponges stress the tip and creates micro cracks, that filter tin in to the core and breake the tip ;-) 
Jul 28, 2011. 3:41 PMSwishercutter says:
I was lucky (or unlucky) enough to be working for a company that required the certificate...so I was even paid to take the classes. Once you are certified you just have to retest to become recertified...mine expired in 2002.

I agree about the sponges...some people overuse the sponge, I only use it if there is dross on the tip. My tip is a few years old and looks new.
Apr 13, 2011. 8:56 PMSwishercutter says:
Normal 60/40 lead tin rosin core solder only needs about 700deg fahrenheit. I typically run my temperature controlled iron between 700-750 depending on my tip and what I am working with. There are temperature charts for what solder you are working with.

Buy 3 to 4 different size tips. A fine point, med point and a large tip. Change the tip for the part not the iron temperature. That is one thing it took me actually working as a solderer to understand. I used to just crank up the stock tip that came with the iron til it melted whatever now if I am soldering something large like 10ga wire or metal parts with large amount of heatsinking I use the big one, for SMT you have to have a very fine tip, the general weller tips that come with the kit are good for Through hole and doing 12ga and smaller wires.

If you want a real good iron I recommend the Hakko 936 or something similar.

Also, there is a big difference between power controlled and temperature controlled irons...if it has just numbers it is power controlled (the one I had i just ran in the middle range). Temperature controlled actually has a feedback thermistor which holds the tip at a specific calibrated temp.
Apr 13, 2011. 2:55 PMscraptopower says:
My soldering tip looks the same. I find it hard to keep the solder tip in good condition.
Jul 22, 2011. 4:11 PMMandingaRes says:
Excelente proyecto!! y no solo para trabajar con un arduino o cualquier microcontrolador... hasta se puede manejar manualmente con solo un par de pulsadores y fabricar un juguete el fin de semana!!
Además de sencillo y práctico es muy fácil de armar con componentes rescatados de alguna placa vieja tirada en algún rincón del taller sin necesidad de ir a la tienda a comprarlos.
Mis felicitaciones!
Jun 21, 2011. 7:22 PMjchurchill-1 says:
I take it the TIP120 transistors have built in flyback diodes?

It just seems that this circuit should definitely have one, possibly 2 for the motor power transistor too.

Nice work though, never occurred to me to use a PWM pin for speed control as well as power control.
Jun 13, 2011. 4:58 PMjag3498 says:
how much power does this supply the motor?
May 17, 2011. 7:53 PMTheWaddleWaaddle says:
H-Bugs XD

-TheWaddleWaaddle
Apr 13, 2011. 4:41 AMwfelix says:
it's not beautiful, but works... and is cheap :D.

Almost sovietic tech, hehehehe
Apr 18, 2011. 2:32 PMicsnerdics says:
soviet tech was anything but that.

though i like this project.
Apr 19, 2011. 4:24 AMwfelix says:
Sorry about the joke... I call "soviet tech" everything is ugly for eyes but it works perfectly... I'm a fan of these things!
Apr 14, 2011. 12:45 PMalexmac131 says:
Bah! I say to those who are critical of your tools.. Let them build a better way and then find fault.


Nice project, should mention its for one engine only, I just finished your RAT for my own needs, works well.

Apr 18, 2011. 5:38 AMbudabob07 says:
Just use an H-bridge. Only needs 4 mosfets
Apr 17, 2011. 12:37 PMPaulMakesThings says:
"Let them build a better way and then find fault."

Well I wasn't going to say anything, but since you asked.
An L298n or other ready made H-bridge IC is better able to handle high frequency pwm, which relays are very inefficient at. It also switches on with a fraction of a volt and as you can see, requires minimal other components. Since it is designed to do just this task it's protection diodes and amplification are built in.

Here's an example diagram, just replace the 3 wires to the pic with enable and direction wires from the Arduino:
http://www.pyroelectro.com/tutorials/l298_control/img/schematic.gif

I don't mean to be rude, this method is still very valid for controlling motors too large for IC drivers.
1-40 of 54next »

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!
51
Followers
4
Author:nothinglabs(Nothing Labs)
Hi, I'm Rich Olson (nothinglabs.com). I sell cloud chambers for viewing radiation, make robots and dev software. I like Instructables with complete info on doing cool stuff with cheap / common parts.