Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Wire a DC motor to a board safely

Use when: a board's pin must turn a brushed DC motor on and off, in one direction

Goal: a circuit where the pin only signals, the motor's current comes from its own supply, and no spike or sag reaches the board

Taught in Driving motors safely

  1. 1

    Take both from the motor's datasheet, or measure the winding's resistance and divide the supply voltage by it.

    Example

    A 6 V motor whose winding measures 4 Ω: stall current about 6/4 = 1.5 A.

    Why: the stall current, not the running current, sizes the supply, the MOSFET and the diode.

  2. 2

    A supply that can deliver the stall current, with its negative side wired to the board's GND.

    Example

    A 4 × AA pack (about 6 V) for this small motor, minus to GND.

    Why: the board's own supply would sag, and without the joined ground the gate has no reference.

  3. 3

    R_{DS(on)} specified at or below your pin's HIGH, drain-source rating well above the supply, current rating well above stall.

    Example

    On an ESP32-S3: an AO3400A (48 mΩ max at 2.5 V, 30 V); at 1.5 A, P = 1.5^2 \times 0.048 \approx 0.11 W.

    Why: a MOSFET that is only partly on overheats at exactly the moment the motor draws most.

  4. 4

    Flyback diode across the motor, cathode to +; bulk capacitor across the supply; gate resistor and pull-down.

    Example

    A 1N5819 across the motor, 470 μF rated 16 V across the 6 V supply, 100 Ω gate resistor, 100 kΩ pull-down.

    Why: each part covers one failure: kickback, supply sag, gate current pulses, and a floating gate at boot.

Common mistakes

  • Powering the motor from the board's 5V pin "because it's a small motor".
  • Forgetting the ground wire between the motor supply and the board.
  • Fitting the flyback diode the wrong way round, which shorts the supply through the MOSFET.
  • Choosing the MOSFET from its running current instead of its stall current.