Tri-state one wire motor control
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.