Let's Make Robots!

Tri-state one wire motor control

Controls small DC motors using a single I/O pin.
BD681-2.pdf87.97 KB
BC337-338_NPN.pdf27.63 KB
BC327-328_PNP.pdf49.5 KB

There may be times when you have a limited number of I/O pins and you want to drive a small DC motor. You could convert a servo for continuous rotation but servos can be expensive or perhaps the gear ratio is not suitable. Most "H" bridges use 2 wires to control a motor with one wire being direction and the other PWM to control speed.

This simple circuit uses the tri-state ability of MCU pins to control a motor from a single I/O pin. When the I/O pin is high the motor will run forward. When the I/O pin is low the motor will run in reverse. When the I/O pin is changed to input (high impedance) the motor will stop. A typical use for this control circuit would be a simple drumming robot where you simply want to drive a drumstick up or down.

The main disadvantage here is that you cannot use normal PWM functions to control speed as the motor would simply run forward and backward very quickly. This would waste a lot of power as the motor would effectively be stalled. You will need to write code that changes the pin between input and output instead.

In this schematic I have not used flyback diodes because the combination of PN transistor junctions and the LEDs will perform that function.

How it works

Assume a supply voltage of 6V and that the forward voltage drop of my yellow and blue LEDs are 3V each. When my I/O pin is configured as an input it has no affect on the circuit. the combined forward voltage drops of the transistor PN junctions and the LEDs from V+ to ground is 7.2V so no current flows through the circuit which only has 6V.

If my I/O pin goes high (5V) then Q1 is held in the "off" state by R1 and no current flows through LED1. Current flows through R5, LED2 and resistor 2. As LED2 drops 3V this still leaves aproximately 2V on the base of Q2 turning Q2 on. As the base/emitter voltage of Q2 is 0.6V this means the voltage across R5 is 1.4V (5V - 3V - 0.6V). This allows aproximately 9mA of current to flow through LED2 making it light up and saturating Q2.

With Q2 on, R6 is pulled down to ground. This allows current to flow through the PN (Emitter/Base) junction of Q3, LED3 and R6. This turns on Q3 and allows aproximately 9mA to flow through LED3. Now both blue LEDs are lit and power runs from +V through Q3 to the motor and then through Q2 to ground causing the motor to spin. Q4 is held in the "off" state by R4.

When my I/O pin goes low the opposite happens. Q1 turns on, this turns on Q4. Both yellow LEDs light up and the motor spins in the opposite direction.

No flyback diodes are used in this schematic as the small coreless motors generate less "Back EMF" than standard DC motors. C1 shorts out most of the electrical noise and some of the "Back EMF". If you are using a standard DC motor then add some flyback diodes to be safe.

The transistors shown in this circuit are rated for a maximum of 800mA which should be plenty for most small motors. For larger motors try using BD681 NPN and BD682 PNP transistors. These are darlinton coupled transistors with a 4A current rating and built in flyback diodes.

Note: the supply voltage should not exceed 6V (7V max) otherwise a short circuit could occur.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I like the way you've gotten around the possibility of short circuiting the power supply that is intrinsic in most of the drivers I see on the web.  You get an "Attaboy" and a smiley face...      :-)


Whoo Hoo! I got a Danny boy smilely face :D

On a more serious note, the only problem with this design is it works on a very limited voltage range. This circuit was intended for use with 4x NiMh batteries (4.8V).

Well, my first idea was to replace the LEDs by Zener diodes. This would allow to adjust trigger voltages. This would also allow higher motor voltages if Zener voltages are chosen appropriately. However, you have to assure that only minimal current flows at lower voltage. Consider the datasheet. Shunt voltage references seem to be even more appropriate - and they are not expensive at all.

Just an idea. Not tested. However, interesting since I am a fan of low pin count processors.


Thanks oddbot! Welcome these compact nice designs :)

Anybody interested in "tri-stating" and "limited pin motor controlling" (bit bureaucracy here )Nuumio has made nice view on this and has some pics and video too. http://letsmakerobots.com/node/17370.

Thanks for the tutorial.

Hey Odd-bot, just realized your location is Zhongshan, are you still there? that's where I grew up!

do you have a workshop or something there?? 

Nice tip OddBot, I'm sure there are plenty of small robots that could make good use of having a few extra pins =)

I used a similar trick to make a half H-bridge not too long ago, but I used a pair of 15V Zener diodes instead of LEDs, because the system was running on 24V. You could always add a Zener to your circuit if a higher supply voltage was needed, either that or add more LEDs (who doesn't like more LEDs anyway?).

Yes, I had already considered Zener diodes. If I get time I will update this post with some other versions of the schematic. The original circuit was for a coreless motor running on 5V.

that's brillant to use LEDs.  Shear genius!

Awesome tip Sir!

BTW, may I ask what software you used to create your schematic?