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.

Step 1: 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

Here's a picture of the complete circuit on a breadboard, with some additional part labels.

Step 3: How to Use It

This circuit is designed to run a motor from the same power source as your microcontroller. Setting I/O pin 1 high makes the motor spin in one direction, and setting pin 2 high makes it spin in the other. Setting both pins low stops the motor, so speed control can be achieved through a PWM signal to a pin. I should also mention that setting both pins high at the same time shorts your battery, and should be avoided. I used a 12 volt power supply I made, but you could go as high or low as your transistors can handle. If you are driving very large motors, I recommend putting the MOSFETS on a heatsink or fan. Attached is a video of the circuit in action. 

I'm connecting the transistor gates to positive by touching them with a jumper wire in this video, but they also are easily switched by two microcontroller I/O pins. I put a piece of red tape on the motor shaft to make it easier to see.

Step 4: How It Works

When you set pin one high with your microcontroller, the NPN transistor Q7 switches on. This connects the base of the PNP transistor Q5 to ground, turning it on as well. Q5 then connects +12 volts to the mosfets Q1 and Q4, which connect the motor to positive and ground. Setting pin 2 high connects the motor to positive and ground in the opposite polarity. The four diodes protect your transistors from voltage surges that sometimes occur when a DC motor is abruptly stopped. The 10K ohm resistors pull the bases of the transistors to ground when your I/O pin goes low, and the 2200 ohm resistors limit the current that can be drawn from your I/O pins to protect them. Have fun spinning motors! I used two of this circuit for the drive train of my robot butler.
<p>I'm considering making these as kits and selling them. Would anybody be interested in buying a kit if I go through with it?</p>
<p>Yes this circuit seems to work exceptionally well, A PCB version would be preferable for durability and professionality. Maybe a variety of circuits with different power handling capabilities. Like a little pack you get with the PCB and the components and you solder them on yourself? </p><p>I would like to thank you for this circuit as I was able to adapt it further to create a robot arm controller and control 5 motors with this one circuit. </p>
<p>On what? A breadboard or a circuit board?</p>
<p>Presumably a circuit board. I was thinking a solder-it-yourself type of kit that comes with the necessary parts and a pcb. I could probably do a breadboard or veroboard instead though. What would you prefer?</p>
<p>id be exceptionally interested<br>higher voltage/amperage ones would be a must for my applications though :)</p>
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!
Glad to hear it worked for you! Heat sinks are your friend
<p>I made on Proteus and i am going to make it real. Thanks for now.</p>
Very good circuit. It works great
Very good circuit! driving a DC motor with Mosfets. I simulated your circuit with proteus and works great, I builded it up and works pretty good.
Can you please tell me how i connect my arduino or motors to this type of motor driver .<br>
<p>I am curious how you turn on the high side N-MOSFETS in your circuit. To turn these on the gate voltage would need to be significantly higher than the source. In other words, you would need a separate voltage source which supplies the voltage to charge the high side gates. I am unsure why your schematic would even work as the high side MOSFET source is close to 12V already. </p>
<p>Hi,thank you for this great project. I want to control the speed of the motor using pwm with Arduino. How can I do that using this circuit ?</p>
<p>Can you add a simple circuit to run this dc controller with only 1 pmw input which is similar circuit to a L293D driver? I have a Kyosho 370 dc motor.</p>
<p>Hey nice work, but i will ask why did you use NPN and PNP transistors back to back? Cant you connect NPN transistors directly to N-Mosfets, it will work aswell?</p>
<p>Hey nice work, but i will ask why did you use NPN and PNP transistors back to back? Cant you connect NPN transistors directly to N-Mosfets, it will work aswell?</p>
Hi dude...<br>I m giving power supply of 12 volts but only getting about 8 volts at motor o/p...this voltage would give low rpm nd low power to motors.pls help me i want full 12 volts output @ output.i hav used bc557 and bc 547 transistors and corrected the emitter collector of Q5 ND Q6 as stated by u but then also m getting only 8 volts which is not sufficient to run the motors..pls reply ASAP...<br>-Thnks in advance... :-)
I am designing a thermostat circuit using 741 op amp as a comparator, 555 timer as adjustable pulse with controlled DC and a MOSFET fire the dc motor control. Would your application work with this?
<p>great project</p><p>can i place your project on my website.</p><p>i'm working on a website which is related to electrical projects.</p><p>i also mention your name, link and other info.</p><p>plz reply</p>
<p>Sure, as long as you credit me and link here! What's your website? :)</p>
<p>Do the Mosfets need a heat sink</p>
<p>If you drive a motor that draws a lot of current they might need heatsinks. I didn't need any with the little motor I used to demonstrate it though.</p>
<p>Also can I use 3904 and 3906 transistors?</p>
<p>What kind of voltage do you see at the motors with this circuit? Doesn't having N channel mosfets on the high side of the motor cause a large drop since the gate voltage is the same as source voltage?</p>
<p>Using this circuit we are trying to drive a dc motor, if supply is 7.2V, the motor gets around 3.5V. I think the bjt part can not put mosfets into saturation mode because the appropriate voltage difference between pnp's base and collector is missing. We now try using a smaller mosfet instead of the pnp's.</p>
Can i control the speed of the motor using pwm arduino?
<p>Yes you can!</p>
<p>this circuit will on with any remote or special remote?</p>
<p>what is the device on the far left and what is the entire use of it? I haven't seen it before. Also how quickly would we be able to get a kit from you if it's still possible?</p>
<p>If you mean the little rectangle on the far left of the circuit diagram, that isn't intended to be a device, it's just a symbol for a port. It shows that two I/O pins connect to the two wires there. I have not actually manufactured any kits yet, since I'm still exploring how much demand there would be for kits. I plan to begin selling kits within a month or so, but nothing is set in stone yet. If you have any on the type of kit you want (breadboard,solder-it-yourself pcb, finished product, etc.) I'd love to hear it.</p>
<p>what is the capacitor in the motor for?</p>
<p>I didn't add that capacitor, it came soldered to the motor. I assume it smoothes the pwm signal the motor receives to make the movement less choppy.</p>
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.
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.
<p>In that case you should probably just experiment with different frequencies until you find one that works. I think raising it might help.</p>
<p>What where the diodes you used? I have a few 1N4007's laying around, would they work?</p>
<p>Those would probably be fine. I just used generic diodes. I'd breadboard it first if I were you just to make sure though.</p>
<p>Those would probably be fine. I just used generic diodes. I'd breadboard it first if I were you just to make sure though.</p>
<p>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!</p>
<p>how many amps does this circuit put out?</p>
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.
<p>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 &quot;L&quot; at the end). </p>
<p>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!</p>
<p>Hi,</p><p>Thanks for such a good information about dc motor controller! :)</p><p>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? </p><p>Otherwise I plan buying a sabertooth 2x25 motor driver which costs 128$ :(</p><p>H-bridge is much cheaper but I think it can not drive 24V motors.</p><p>I'm waiting for any suggestions and recommendations for this project.</p><p>Thanks in advance,</p>
<p>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.</p>
<p>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?</p>

About This Instructable




Bio: I'm a UM engineering student. I like to build robots, machines, and electrical systems based on whatever parts I can scrap out of old ... More »
More by mgingerich:Easy DC Motor Controller How To Make an Optocoupler Small robot made from hacked toys 
Add instructable to: