Robotics and Motion

Motor Drivers and Why Pins Cannot Drive Motors Directly

Learn why a microcontroller pin cannot power a motor, how current demand and back-voltage cause damage, and what an H-bridge motor driver does instead.

On this page
  1. The short answer
  2. Current demand: pins are small
  3. Back-voltage: the motor pushes back
  4. What a driver does
  5. Choosing a driver
  6. Wiring points that save boards
  7. Why it all matters

The short answer

A microcontroller pin carries signals, not power. It can switch a small amount of current, often something like a few milliamps up to a few tens of milliamps depending on the chip, and a motor can want many times that. Connecting a motor straight to a pin risks damaging the pin or the whole chip. A motor driver sits in between: it takes the weak control signal and uses it to switch a separate, stronger supply that the motor runs from. Exact pin limits vary by board, so check the datasheet for the one you use.

Current demand: pins are small

Ohms law links voltage, current and resistance, and it explains why motors are demanding. A motor winding has low resistance, so even a modest voltage across it allows a large current. A rough illustration: a motor winding of 2 ohms across 6 volts would pass 6 ÷ 2 = 3 amps if nothing else limited it. Real motors limit the current as they spin, because they generate an opposing voltage of their own, but at start-up and when stalled the current can be several times the running value.

Several different numbers matter when picking a motor and driver:

  • Free-running current: low, when the motor spins with no load.
  • Running current under load: higher as the load grows.
  • Stall current: the maximum, when the shaft is blocked or just starting. This is the figure a driver must survive.

A pin that tops out at tens of milliamps cannot supply amps. Even if the motor appears to turn weakly, the pin is being overstressed, and damage may show up later rather than immediately.

Back-voltage: the motor pushes back

A motor is a coil of wire, and coils resist changes in current. When you switch the current off suddenly, the magnetic field collapses and the coil produces a voltage spike, often called inductive kick or back-voltage (back EMF is a related but different effect from the motor’s spinning). This spike can be much larger than the supply voltage and has nowhere safe to go if the motor is connected to a bare pin or a bare transistor. It can damage the switching part and send noise into the rest of the circuit.

A motor that is spun by something else, or is still coasting when you cut power, also acts as a generator and pushes voltage back into the circuit. That is another reason driver circuits include protection.

Protection usually takes the form of flyback diodes, which give the spike a path to circulate safely instead of hitting the switch. Quality driver chips build these in, and bare transistor circuits need them added.

What a driver does

A motor driver has three jobs:

  1. Handle the current. Its output stage is built to switch amps, not milliamps.
  2. Take a separate supply. The motor power comes from a battery or supply of suitable voltage, not from the controller’s logic rail.
  3. Respond to simple control signals. Logic-level inputs from the microcontroller decide direction and speed.

The basic building block is a transistor used as a switch: a small current at its control terminal allows a large current through its main path. The principles are in the article on transistor switching. A single transistor can turn a motor on and off in one direction. To reverse direction, drivers use an H-bridge, four switches arranged in the shape of an H with the motor in the middle. Closing one diagonal pair of switches drives current one way through the motor, and closing the other diagonal pair drives it the other way. Closing both switches on the same side shorts the supply, so good drivers prevent that combination, and builders should never command it on a bare bridge.

Common inputs on a typical driver are:

  • A direction signal, or two inputs whose combination sets forward, reverse, coast or brake.
  • A speed input, usually a pulse width modulated signal. The pin switches on and off quickly, and the average power depends on the fraction of time it is on.
  • An enable pin to switch the output stage off entirely.

Stepper motors need drivers that energise coils in sequence, and some servos include their own electronics. The comparison of DC, servo and stepper types covers which needs what.

Choosing a driver

  • Voltage range: it must cover your motor supply with margin.
  • Current rating: compare against the motor’s stall current, not only its running current, and pay attention to whether the rating is continuous or peak only. Many ratings assume good heat sinking.
  • Heat: drivers lose some power as heat, and boards without a heat path may throttle or shut down.
  • Features: current sensing, thermal shutdown and overcurrent protection are useful on modules that offer them.
  • Logic levels: make sure the driver accepts the voltage your controller outputs.

Reading datasheets is worth the time here, because the headline numbers on a product listing can be optimistic.

Wiring points that save boards

  • Share a common ground between the controller and the driver, or the control signals have no reference.
  • Keep motor power separate from logic power. Motor current surges can sag a shared supply and reset the controller. Where one battery feeds both, a voltage regulator for the logic side helps, and decoupling capacitors near the driver absorb surges.
  • Use suitable wire. Motor leads carry real current. Thin wire heats up, and wire gauge and fusing should match the worst-case current.
  • Add a fuse or current limit on the motor supply when practical.
  • Check polarity twice. Reversed supply connections destroy many driver modules.
  • Test unloaded. Run the motor with the wheels lifted or the load removed first.

A multimeter reading of supply voltage while the motor starts can reveal sag that explains random resets. If you use lithium-based batteries, follow the manufacturer’s guidance for charging and protection, as they can deliver very high current into a fault.

Why it all matters

Treating the driver as a deliberate stage, not an optional extra, protects the controller, makes behaviour predictable and gives the robot a place to add safety features. A controller that is separated from motor power can also be paired with a hardware cut-off, so that a software crash does not leave a motor running.

The complete guide to robotics and motion

How Hobby Robots Sense, Decide and Move
Read the guide

Keep exploring

Guides from other topics

All topics →