I've used this simple circuit several times to drive motors (like in my Stair Climbing robot) as well as solenoids. I originally picked it up from this instructable which is focused on controlling a solenoid. I wanted to isolate this circuit in its own Instructable as a motor driver so I could easily reference it from other future instructables and also provide example code to show how to use it in this manner.

Step 1: Parts List

The parts list is pretty short:

  • A 1N4001 Diode
    adafruit has a 10 pack for $1.50
  • A small solderless breadboard
  • Jumper wires
  • A 1K resistor
    (you'll need 2 if you want to add an optional LED which I'll cover later)
  • A DC brushed motor
    (When choosing a motor for this project, note that the TIP120 transistor can handle 5A continuous and 8A peak.)
  • A battery with enough power to run your motor and enough voltage to power the arduino (7-12V)
  • An arduino uno (or other flavor of your choice)... really anything that can supply a pwm signal.

Step 2: Operation Principle

PWM stands for pulse width modulation. This basically means it is a circuit that is being turned on and off (pulsing) and you can change how long it is on and how long it is off (that's the modulation part).

In the world of servos, a PWM signal acts as sort of Morse code... a micro-controller in the servo reads the duration of each pulse and uses that to decide where to turn the motor to.

However, this speed controller is simply fully proportional... that is to say: you can change (modulate) the pulse from all the way off to all the way on and the motor will go from standstill to running at full speed. If the pulse is such that is is on half the time and off half the time the motor will turn at 50% of its maximum speed.

The transistor is using that low voltage / low amp pwm signal and using it to switch a higher voltage, higher amp signal going from the battery to the motor. It is acting as an amplifier in this sense.

An advantage of using this method to alter the motor's speed vs changing the voltage is that you maintain the motor's torque. This is because at any given time the motor is either completely off or completely on.

Step 3: Connecting the Circuit

I've posted the circuit on fritzing:

(Look for the "downloads" section in the lower right.)

I also have the example code on codebender:

Step 4: Options

You can optionally add an LED. The PWM signal will control how bright it glows. So the faster the motor goes the brighter the LED will be!

Just connect the anode (the + side with the longer leg ) middle transistor leg or negative side of the motor - then connect the cathode (the - side of the LED with the shorter leg) to the a 1k transistor which is then connected to the positive power rail.

Powering the arduino with the same battery as the motor is optional but convenient. You don't have to disconnect the Vin pin when you connect the USB to program the arduino since "The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.... external power will be chosen if it's above 7.4V or so, otherwise USB power." - source

This circuit is very simple and only drives one motor in one direction. Though I have duplicated the circuit and driven a Bogie Runt Rover with it (which has 6 motors - I drove the left 3 motors with one of these circuits and the right 3 motors with the other). Since there is no reverse you don't get a full tank style steering but it is certainly maneuverable (in fact I built a line follower using this setup).

<p>Hi All, I want to do the same think but regulating around 60V input, is this circuit applicable? should I change transistor for MOSFET? if so what type? </p><p>btw. I am tottaly green with this stuff so go gentel on me :P</p>
<p>Cool Instructable! We thought it'd be fun to make the simulation in 123D Circuits. Instead of a TIP120 we used an N-MOSFET. We also added an oscilloscope to show your PIN3 PWMing live! If you visit the page press &quot;Start Simulation&quot; to kick it off. https://123d.circuits.io/circuits/1117055</p>
<p>TeamJaeger - you inspired us to add a simulate-able TIP120 to the 123D Circuits Electronics Lab (simulator) so we did that, and we built your exact circuit. Here it is: https://123d.circuits.io/circuits/1133854</p>
<p>oops looks like this link is not working</p>
<p>We can't edit the original comment but this is the circuit from the image with the TIP120: <a href="https://123d.circuits.io/circuits/1148270-simple-cheap-tip-120-motor-controller">https://123d.circuits.io/circuits/1148270-simple-cheap-tip-120-motor-controller</a></p>
<p>Super cool. Thanks guys!</p>
<p>Thanks ! this is really helpful . Any recommendations for controlling multiple motors by this method? @elephlab</p>
If you need them to be controlled independently you would want one of these circuits for each. Otherwise you can just connect more than one motor into the screw terminals. For example I've controlled a small 6 wheel drive rover with two of these circuits - one connected to the 3 motors on the left, the other connected to the three motors on the right.
<p>hi, in step 2, you say: &quot;However, this speed controller is simply fully proportional... that is <br>to say: you can change (modulate) the pulse from all the way off to all <br>the way on and the motor will go from standstill to running at full <br>speed. If the pulse is such that is is on half the time and off half the<br> time the motor will turn at 50% of its maximum speed.&quot; So the arduino gives the pulse, and you command this motor driver instructable to accellerate the motor slow until top speed by regulating the pwm signal with the arduino?</p>
<p>oh, i think u made an on/off switch, commanded by pwm?</p>
<p>I'm using it since extensively. Just for reference, it's discussed in O'Sullivan and Igoe, Physical computing<br>http://www.amazon.com/Physical-Computing-Sensing-Controlling-Computers/dp/159200346X</p>
<p>cool :)</p>
<p>Hi Folks. I think the scematics wrong. You short circuit VIN and GND by the 9V battery and will probably demage your arduino. Plus scematics and break board graphic are different.<br>Can anyone explain why there's a diode parallel to the motor?</p>
<p>When you spin an electric DC motor, it becomes a generator... so when this circuit gets the motor moving at high speed, then suddenly switched off... the motor continues to spin a short time... during this time there is a feedback voltage. The reversing diode allows this voltage to have a path to ground.<br><br>Additionally... when driving a coil... either a motor or a solenoid... when power is applied, a magnetic field is created. When power is removed, this magnetic field collapses. When a magnetic field collapses, there is a reverse power spike... again, this reverse diode allows it to have a path.</p>
<p>A 9v is well within the 7-12v recommended input voltage of an arduino. In fact 6V is the absolute minimum and 20V is the absolute max ( <a href="https://www.arduino.cc/en/Main/ArduinoBoardUno">https://www.arduino.cc/en/Main/ArduinoBoardUno </a> ). I have actually powered arduinos this way with 2S or event 3S LiPos without problems.</p><p><br>In what way is the schematic different?<br><br>Full disclosure: I am by no means an electrical engineer- I just like to make things. My understanding is that the diode will prevent kickback voltage (like if the motor breaks fast) from damaging the circuit by giving it a place to go -- almost like a relief valve on a water heater. </p>
<p>When the voltage drops to zero, there is no torque any more. In fact, the mean torque if you integrate the torque value for a whole PWM period is equal to the torque you could get if you set an intermediate continuous voltage.<br>Consequently, I think you are wrong when you can say that the torque is maintained.</p>
<p>how about driving a linear actuator in both directions? What to do?</p>
<p>Great circuit and write-up. I plan on utilizing this to control my sons modified power wheels.</p><p>One thing I noticed when you described adding an LED you noted &quot;the a 1k <strong>transistor</strong>&quot;, should be <strong>resistor</strong>.</p><p>Thanks for the write up.</p>
<p>Cool controller! One question, how did you do that code thing at step 4? I like it really much and I thought I use it but how?</p>
<p>I used codebender.cc (which is awesome btw) to write the code. Here is one way to do it: <a href="https://www.instructables.com/id/Include-your-codebender-sketch-in-your-Instructabl/">https://www.instructables.com/id/Include-your-codeb...</a></p><p>You could also:<br>1. in codebender choose &quot;share&quot;</p><p>2. choose the &quot;embed&quot; tab and copy the code</p><p>3. in the wysiwyg editor in instructables choose the &lt;/&gt; (HTML) button to edit the source code.</p><p>4. paste in the code you copied</p>
<p>One question how do I enter the wysiwyg editor in instructables?</p>
<p>It might be something that comes with a pro level account. Although this page: https://www.instructables.com/account/gopro does not specifically mention it... the welcome email says &quot;...Your Pro status means<br>you now have enhanced abilities on the site such as rich editing...&quot;</p>
<p>Thank you very very very much!! I could use it for me projects now. Thanks again!</p>
<p>What a brilliant little circuit.</p><p>I'll be able to use this for so much.</p><p>One thing I noticed is that there's a connection missing to the transistor in the second circuit diagram. It's in he first and the image, but not the second.</p><p>Again, what a fantastic little motor controller.</p>
<p>Thanks <a href="https://www.instructables.com/member/tashen" style="">tashen</a>! I've updated the second diagram - good catch!</p>
<p>What transistor did you use for your &quot;stair climbing drive&quot;? at what amperage?</p><p>Thank you.</p>
<p>I used a TIP120. I used a motor that has a stall current of 20A <a href="https://www.servocity.com/html/313_rpm_hd_precision_planetary.html#.Vh0riflViko">https://www.servocity.com/html/313_rpm_hd_precisio...</a></p><p>but my battery could only dish out 2A.</p>
<p>Thank you for this instruction. If I needed to drive 30A continuous, do I need to change the circuit? Or just the transistor? Would you recommend a MOSFET for 30A?</p><p>Thank you very much.</p>
<p>I've thought about trying it with one of these: <a href="http://www.newark.com/international-rectifier/irfb4410pbf/mosfet-transistor-n-channel-96/dp/97K1977?ost=97K1977&mckv=sbn69dOB5_dc%7Cpcrid%7C70498179155%7Cplid%7C%7Ckword%7Cirfb4410pbf%7Cmatch%7Cp&CMP=KNC-GUSA-GEN-SKU-MDC&gclid=CNe6gKStzccCFQoPaQodLrsFlQ">http://www.newark.com/international-rectifier/irfb...</a> </p><p>or one of these: <a href="http://www.newark.com/ixys-semiconductor/ixfh120n15p/mosfet-n-to-247/dp/58M7589">http://www.newark.com/ixys-semiconductor/ixfh120n1...</a></p><p>but I have not tried it yet. You'd also have to choose a resistor and diode that could handle that much power. You'd probably be exceeding what a solderless breadboard can handle at that point also :)</p>
<p>30A? Shouldn't you power that by adding a 40A SSR to the circuit?</p>
<p>I presume you specified 7.4V as that means you can use any 2S LiPo. I like those rechargable lithiums that are in the 9V battery format such as these: http://www.amazon.com/gp/product/B0088R79RE which I find quite convenient for portable projects - in my case with the Raspberry Pi (although that requires and 5V buck converter for $3, eg http://www.aliexpress.com/snapshot/6050379977.html )</p>
<p>I've actually been using it with a 3S LiPo... I've also used it with an old 12v sealed lead acid. But any 7-12v battery should power the arduino just fine... if you want to go with more than 12v you'd want to power the arduino separately (but keep the grounds connected). The TIP120 can handle up to 60V.</p>
<p>Pictorials are good, but schematics are even better, could you add one?</p>
<p>for the code :</p><blockquote>analogWrite(pwmPin, maxSpeed);</blockquote><p>should be:</p><p>analogWrite(pwmPin, speed);<br><br>otherwise the motor will just be spinning all the time.</p>
<p>Typo caught and corrected... thanks much <a href="https://www.instructables.com/member/Atomic3xplosion" style="">Atomic3xplosion</a></p>
<p>great idea...</p>

About This Instructable




Bio: I work at RobotZone ( the folks behind Actobotics and ServoCity.com ) in Winfield, KS. I love working on projects with my kids and seeing what ... More »
More by TeamJaeger:DeathGrip: Robot Claw Gauntlet Lightweight Weed Whacker RC Fireworks Truck 
Add instructable to: