Introduction: Build Your Own Inexpensive H Bridge
Build your own efficient H Bridge for driving motors, and other loads that need to be driven bidirectionally.
Start with an ebay purchase:
100PCS AO3401 A19T 4.2A/30V SOT23 P-Channel MOSFET SMD transistor ($2.50)
100PCS AO3400 A09T 5.7A/30V SOT23 N-Channel MOSFET SMD transistor ($2.50)
Arrange the transistors with 2ea. P type on top, and 2ea. N type below. Add an enable transistor. See circuit diagram. Solder the SMT transistors to the perfboard. Note they need to be slightly offset to fit to the 0.1" circuit board pads.
Finally, test out the H Bridge. The battery should put out no more than the microcontroller can handle. Put a small motor across the output, (with a parallel led with a series resistor if desired). Program an ATtiny85 or Arduino with the code provided. The motor should move one way for a few seconds, stop, and reverse direction. Install Schottky diodes across the transistors to limit reverse voltage spikes, especially for bigger motors. Note that you can simplify the wiring from the H Bridge to the ATtiny by combining gate drives on the left and right sides of the Bridge (connect the gate of the bottom right FET and top right FET to PB1, and bottom left FET and top left FET to PB0), and the sketch still works. Thus PB3 and PB4 are free for other uses.
If you want to use a higher voltage for the motor than the microcontroller uses, you need to add an additional 2 transistors to avoid shoot through, which will kill the H Bridge and, likely your microcontroller too. This is because the P mosfet gates won't get driven to a high enough level to insure turn- off, while the N mosfets would be driven fully on. Add the additional 2 transistors as shown in the circuit diagram.