Skip to content

Motor Driver

You'll pick a transistor by reading its datasheet, split the heavy current from the board's logic, and run a gearmotor at four speeds in both directions from a pin.

About

A microcontroller pin gives you 20 milliamps and a motor wants an amp, or ten at stall. The bridge between them is a transistor you choose by reading its datasheet rather than by copying a forum post, and a power layout where the motor's current never crosses the board's thin traces. Once you know what gate threshold, continuous current, a flyback diode and a common ground mean, you can drive motors, solenoids, pumps and heaters from here on. Fuse the motor supply. A stalled motor on an unfused lithium pack melts insulation in seconds.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
A week of evenings
Skill level
Intermediate (months of practice)
Cost
Moderate (under $100)
Supplies
You need some
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Microcontrollers & Robotics to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Measure the stall current of a small DC motor. A motor from a broken toy or a ten-dollar gearmotor is fine. Hold the shaft still for one second with the meter in series on the 10 A range. That's the number your driver, your wires and your fuse all have to live with. Take a photo of the reading. Photo
  2. 2
    Pick a logic-level MOSFET from its datasheet and write down the three numbers that qualified it. You want a gate threshold low enough that your 5 V or 3.3 V pin turns it fully on (check the on-resistance at your gate voltage in the table, not just the threshold line), a continuous drain current above your stall figure, and an on-resistance low enough that it won't cook. Take a photo of the datasheet page with those three values circled. Photo
  3. 3
    Build the low-side switch with a gate resistor, a pull-down, and a flyback diode across the motor. Skip the diode and the motor's collapsing field spikes the transistor every time it switches off. Take a photo of the circuit with each part labeled. Photo
  4. 4
    Run the motor from its own fused supply, joined to the board by ground alone. A 4xAA pack, a 2S lithium pack with a protection board, or a 12 V adapter, with a fuse in the positive lead sized just over the running current. The only wire between the motor supply and the board is ground, and the motor current must never pass through the board's 5 V pin or its USB cable. Anything carrying an amp or more should be 22 AWG or thicker. Take a photo of the wiring with the fuse and the single ground link visible. Photo
  5. 5
    Control the speed with PWM and show four speeds. Use analogWrite from 50 up to 255. Note the value where the motor first turns, because below that it just hums, and note whether raising the PWM frequency quiets the whine. Film the four speeds. Video
  6. 6
    Add a second direction with an H-bridge module, then run at full load for ten minutes and check temperatures. An L298N or TB6612 module costs a few dollars and gives you forward, reverse, brake and coast. Load the motor for ten minutes (a brake on the shaft, or lift a weight on a string), then check the transistor and the wires with a finger after powering down, or with an infrared thermometer. If you can't hold a finger on it, add a heatsink or pick a better part, and say why. Film the reversal and include the temperature in the frame or your note. Video