Picture of Easy DC Motor Controller
DC Motor Controller.bmp
If you're building a robot or other microcontrolled gadget, you will need to drive DC motors forwards and backwards. In this instructable, I'll demonstrate a simple and inexpensive circuit that controls a DC motor from two I/O pins. It requires no integrated circuits, and uses commonly available parts. I recommend you build it on a breadboard the first time. I designed this circuit, but I'm not the inventor of this type of motor controller. I got interested in motor control circuits like this one when I saw the amazingly precise movements of the Makerbots and CNC routers at Maker Works in Ann Arbor.
Remove these adsRemove these ads by Signing Up

Step 1: Parts List

Picture of Parts List
Here are the parts you'll need. All of them should be available at your local RadioShack or hobby store.

(1) DC motor

(4) MOSFET transistors. I used the IRF540N, but any N-channel MOSFET will do.
(4) Diodes

(2) NPN bipolar transistors. I used the BC548.

(2) PNP bipolar transistors. I used the BC327.

(4) 2200 ohm resistors (red-red-red)

(4) 10K ohm resistors (brown-black-orange)

Some jumper wires and a breadboard, if desired

The resistor values are not critical. Values that are fairly close will most likely work fine. 

Step 2: The Finished Circuit

Picture of The Finished Circuit
Here's a picture of the complete circuit on a breadboard, with some additional part labels.
mgingerich (author) 26 days ago

I'm considering making these as kits and selling them. Would anybody be interested in buying a kit if I go through with it?

id be exceptionally interested
higher voltage/amperage ones would be a must for my applications though :)

atenwesteneind10 months ago
Hey thank you for this awesome circuit, used it in a trade school project for proportional forward and reversing relative to temperature. I used the IRF511 MOSFETS and boy do they get hot!
mgingerich (author)  atenwesteneind10 months ago
Glad to hear it worked for you! Heat sinks are your friend
frtrev11 days ago

what is the capacitor in the motor for?

Haroldcrick1 month ago
Will this motor work by putting a PWM signal on the I/O pins? I'm trying right now and I cannot get the motor to spin backwards by changing the duty cycle.
mgingerich (author)  Haroldcrick1 month ago
A pwm signal should cary the speed of the motor. What sort of duty cycle signal are you feeding it? Is it behaving oddly or not spinning at all?
I had forgotten to put diodes in... It was behaving oddly but it is rectified now. One more quick thing, what frequency would you recommend, I would like it to not spin at 50 percent duty but it seems to spin slowly.
mgingerich (author)  Haroldcrick1 month ago

In that case you should probably just experiment with different frequencies until you find one that works. I think raising it might help.

Con_D2 months ago

What where the diodes you used? I have a few 1N4007's laying around, would they work?

mgingerich (author)  Con_D2 months ago

Those would probably be fine. I just used generic diodes. I'd breadboard it first if I were you just to make sure though.

mgingerich (author)  Con_D2 months ago

Those would probably be fine. I just used generic diodes. I'd breadboard it first if I were you just to make sure though.

KyleC52 months ago

Sooo, quick question about H-Bridge's in general. I've designed about 4 different versions (Including modeling this one) of these type of drivers. But I keep having the same problem where my High voltage is 12V, but the output to the motor is only about 8.5V :/ Does anyone know why this is and if there is a work around? TY!

bmiller733 months ago

how many amps does this circuit put out?

mgingerich (author)  bmiller733 months ago
I haven't tested the circuit under extreme conditions. According to the datasheet for the mosfets, they can handle up to 33 amps before they break. I bet you'd need a giant heatsink on them though. If you want to drive even bigger loads, you could switch to a different kind of mosfet that can handle more current. My power supply is kind of wimpy, so I couldn't push the circuit to the limit.
agr00m5 months ago

Interesting design. I'm wondering what's the purpose of having an NPN turn on a PNP, turn on a MOSFET. Do you know if there's an advantage to this design over driving the MOSFETs directly from the MCU? You'd just need a logic level MOSFET like a FQP30N06L (or any with an "L" at the end).

mgingerich (author)  agr00m5 months ago

I found that switching the FETs directly from the microcontroller didn't work very well because I was using a Parallax Propeller, which has a logic level of 3.3 volts. Switching the FETS with this low a voltage wouldn't turn them on all the way and limited the maximum motor speed. The transistors allow me to feed the gates of the FETS 12 volts, which is more than enough to turn them on. You could be right about the logic level MOSFETS, try it and let me know how it goes!

Akbar131 year ago


Thanks for such a good information about dc motor controller! :)

I'm planning to make a Segway using Arduino Uno microcontroller. I have two 24V 250W DC motors. Is it possible to control them using this circuit? If it's possible do I have to make two such circuits?

Otherwise I plan buying a sabertooth 2x25 motor driver which costs 128$ :(

H-bridge is much cheaper but I think it can not drive 24V motors.

I'm waiting for any suggestions and recommendations for this project.

Thanks in advance,

agr00m Akbar135 months ago

The circuit should work, but you'd have to choose the proper MOSFETS and PNP transistors. If you plan on having a single 24v source, the PNP transistors would need to handle 24v collector-emitter voltage, and the MOSFETS a continuous drain-source current of 12A. Though I'd ensure the components are capable of values much higher to be safe, especially the MOSFETs.

mgingerich (author)  Akbar131 year ago

It's possible to control them using a circuit like this, but you'd definitely have to use different mosfets that could stand up to the high power. If you put them in parallel and add heatsinks and fans you should be able to get it to work. You'd also have to use a 24 volt battery and regulate it down for your arduino. If it might save you $250 then it's worth a shot, right?

Thanks for your reply,

I ask you because you have an experience, could you please provide me parts list like in step 1 above to control 24V 350W or 250W dc motor.

Below I provided a link for the details of motor, I would appreciate your help thanks

sacnorth8 months ago

This article really rocks, But here we used more components, for a simple project of mine where i just wanted to drive a motor from my arduino board , i found the very simple circuit here"

I think this will help for people who need a simple driver using a transistor switch

agr00m sacnorth5 months ago

The difference between the two is this circuit provides bidirectional movement (forward & reverse), where yours only provides a single direction (forward). Just depends on the needs of your project.

jp-diy8 months ago

Very nice circuit , I am trying to built this WE

2 questions

what is the aim of bipolar transistor ?

I use IRFZ24, I think diodes are not mandatory because there are integrated to mosfet ?

thank you

mgingerich (author)  jp-diy8 months ago

The bipolar transistors allow you to connect 12v to the gates of the MOSFETS when you turn them on. Without them, the microcontroller would only connect 5v to the MOSFETS, and the they wouldn't turn on all the way. This limits the power you can deliver to the motor. You're right about the diodes, they aren't mandatory if your MOSFETS have them internally. I still use them as an extra precaution, in case someone builds this circuit with different components than I did.

Gabse1 year ago
wankeye1 year ago
Thanks, I tried this with zero knowledge besides a Google search of various H-bridges and I had pretty poor results. I look forward to looking at yours to see where I went wrong and to try again!
nroche1 year ago
Hey. I can see where the collector / emitter confusion has come from - it's wrong in the PNP circuit on that Adafruit quick reference sheet you linked in. In principle that sheet would be great, but in practice its really not good. They have also made very dangerous generalizations about device pinouts which are definitely not safe blanket statements - they could well confuse the beginner / hobbyist users who they are aimed at even more! Silly people! My advice: take the link down - it will do more harm than good and frustrate people who are trying to learn how this stuff works.
Anyway, that's my 10 cents. Nice instructible though - pretty straight forward and I think I might just use this.
mgingerich (author)  nroche1 year ago
Thanks, looks like I fell into that trap! That reference sheet worked for me, but I probably just had forgiving transistors. I took the link down, maybe I'll find a more accurate one. Wouldn't want to confuse my fellow electronics geeks!
Wyle_E1 year ago
Quibble: the control element of a bipolar transistor is called the base, for historical reasons.

This "H-bridge" configuration is so common that it's available as a single chip from the companies that make power MOSFETs.
mgingerich (author)  Wyle_E1 year ago
Good point about the transistor's base, I'll fix that. I know you can buy integrated circuits that will do this, but where's the fun in that? I try to avoid using ICs in my projects because it forces me come up with my own solutions and I like to use salvaged parts. Thanks for the input!
profpat1 year ago
nice circuits!
mgingerich (author)  profpat1 year ago
Thanks :)
mgingerich (author) 1 year ago
It's been brought to my attention that Q5 and Q6, which are BC327 PNP transistors, appears have their emitter and collector swapped in my diagram. They worked fine for me in this configuration, but you might get different results if you use different transistors. If the MOSFET section of the circuit works, but you have trouble getting the BJTs to switch them, try reversing the emitter and collector.