Creative Hardware

H-Bridges and Motor Drivers: Getting Started

A microcontroller pin can't drive a DC motor directly — it can't supply enough current, and it has no way to run the motor backward. An H-bridge solves both problems with four switches arranged in a pattern worth actually understanding.

If you’ve ever wired a DC motor straight to a microcontroller’s GPIO pin and had it either not spin, or worse, damage the board, you’ve run into the two problems an H-bridge exists to solve. A microcontroller pin typically supplies only a few milliamps at 3.3V or 5V — nowhere near enough current for most motors, which can draw hundreds of milliamps or more under load. And a GPIO pin only knows “on” or “off”; it has no built-in way to reverse a motor’s direction. An H-bridge fixes both at once.

Why it’s called an “H”

The circuit gets its name from its shape on a schematic: four switches (in practice, transistors) arranged so that the motor sits across the middle of an “H,” with power and ground available on each side. By turning on diagonal pairs of switches, current flows through the motor in one direction; by turning on the other diagonal pair instead, current flows the opposite way, and the motor spins in reverse. Turn off all four switches, or turn on only switches on the same side, and the motor coasts or brakes depending on the specific configuration.

This matters because it means direction control is just a matter of which two switches you activate — no mechanical reversing linkage, no separate forward/reverse motor, just different combinations of the same four components.

Speed control: PWM, not a separate circuit

H-bridges don’t need a separate mechanism for speed control. Instead, you rapidly switch the active diagonal pair on and off using PWM (pulse-width modulation) — the same technique used for dimming LEDs or controlling servo position. A motor driven with a PWM signal at, say, 30% duty cycle receives full voltage for 30% of each cycle and nothing for the rest; because the switching happens fast enough (typically above 1kHz, well above what the motor can mechanically respond to individual pulses for), the motor averages that out into a proportionally slower, smoother rotation rather than a stutter.

You don’t build the H-bridge yourself — you use a driver chip

In practice, almost nobody wires four discrete transistors into an H-bridge by hand anymore. Instead, you use a motor driver IC that packages the whole arrangement — plus protective circuitry against voltage spikes when the motor’s magnetic field collapses — into one chip. Two of the most common for hobbyist projects:

  • L298N — an older, widely available dual H-bridge chip, often sold on a breakout board with screw terminals. Handles higher current and voltage than most alternatives, at the cost of being noticeably less efficient (it drops several volts across itself, which matters on battery-powered projects).
  • DRV8833 — a newer, smaller, more efficient dual H-bridge, well suited to small DC motors and battery-powered builds where every bit of efficiency matters.

Both chips take two inputs per motor — typically labeled something like IN1/IN2 — where the combination of high/low on those two pins determines direction (and PWM-ing one of them controls speed), while the chip itself handles sourcing enough current to actually drive the motor from your microcontroller’s logic-level signals.

A basic wiring pattern

A typical setup: the driver chip’s logic-level inputs connect to microcontroller GPIO pins (one of which is a PWM-capable pin for speed control), the chip’s motor-power input connects to a separate, adequately-rated power supply or battery (not the microcontroller’s own 3.3V/5V rail, which can’t supply enough current), and the motor itself connects to the driver’s output terminals. Driving the motor from a separate power rail than your microcontroller’s logic is the detail beginners most often skip, and it’s usually the reason a project either doesn’t work or resets the microcontroller under load — a motor’s current draw can cause enough voltage sag to crash a shared power rail.