To drive a DC motor or high-current inductive load with a microcontroller PWM pin, use a low-side N-channel logic-level MOSFET topology paired with a Schottky flyback diode and a 10kΩ gate pulldown resistor. This configuration switches the ground path, keeping the load tied directly to the positive supply rail while the microcontroller safely toggles the return path via a 3.3V or 5V logic signal.

The Low-Side N-MOSFET PWM Topology

A robust PWM driver requires more than just wiring a microcontroller pin to a transistor gate. The circuit relies on six critical nodes: MCU_PWM (the logic output), GATE, DRAIN, SOURCE, V_MOTOR (the positive load supply), and SYS_GND (the shared ground reference).

The MCU_PWM node feeds through a 100Ω series resistor (R1) to the GATE of the MOSFET. A 10kΩ pulldown resistor (R2) ties the GATE to SYS_GND. The SOURCE connects directly to SYS_GND. The DRAIN connects to the negative terminal of the motor, while the motor's positive terminal connects to V_MOTOR. A Schottky diode (D1) is placed in reverse bias across the motor terminals (cathode to V_MOTOR, anode to DRAIN) to clamp inductive kickback.

Design Walkthrough & Component Selection: For a 12V, 3A DC motor driven by an ESP32 (3.3V logic), we select the IRLZ44N. Unlike standard MOSFETs that require 10V to fully enhance, the IRLZ44N is a logic-level device with a gate threshold voltage (Vgs(th)) of 1.0V to 2.0V and an Rds(on) of just 22mΩ at 5V Vgs. At 3.3V, it still comfortably passes 3A with minimal thermal dissipation.
Component Specification & Design Values
RefComponentValue / Part NumberParameter / Design Reason
Q1N-Channel MOSFETIRLZ44N (TO-220)Vgs(th) 1-2V, Rds(on) 22mΩ @ 5V, Id 47A max
R1Gate Series Resistor100Ω (1/4W Carbon)Limits di/dt inrush, dampens LC gate ringing
R2Gate Pulldown Resistor10kΩ (1/4W Carbon)Bleeds gate charge, prevents floating during MCU boot
D1Flyback Diode1N5819 (Schottky)Vf 0.6V, reverse recovery time <10ns, 1A continuous

Circuit Behavior Under Parameter Changes

Understanding how component variations affect switching dynamics is critical for thermal management and EMI control.

PWM Circuit Behavior Matrix
Parameter ChangedEffect on CircuitThermal / Electrical Consequence
PWM Duty Cycle ↑ (10% to 90%)Motor RMS voltage increasesMotor speeds up; MOSFET conduction losses increase linearly with duty cycle.
PWM Frequency ↑ (1kHz to 20kHz)Switching transitions multiplyGate drive losses (Qg × Vgs × f) increase linearly. MOSFET may require a heatsink above 15kHz.
R1 Value ↑ (100Ω to 1kΩ)Gate RC charge time increasesSlower switching edges. MOSFET spends more time in the linear region, causing massive switching heat.
Load Inductance ↑ (Fan to Winch)Flyback spike energy (1/2 L I²) increasesD1 must dissipate more heat. Standard 1N5819 may fail; upgrade to SS34 or fast-recovery UF4007.

Why Low-Side N-MOSFET Over the Alternatives?

Beginners frequently reach for the TIP120 Darlington BJT or attempt high-side P-MOSFET switching. Both introduce severe penalties in efficiency and complexity compared to the low-side N-MOSFET topology.

Topology Comparison: Low-Side N-MOSFET vs. Alternatives
CriteriaLow-Side N-MOSFET (IRLZ44N)Low-Side BJT (TIP120)High-Side P-MOSFET
Voltage Drop at 3A~0.066V (I × Rds(on))~2.0V (Vce saturation)~0.1V (depends on Rds(on))
Heat Dissipation at 3A0.198W (No heatsink needed)6.0W (Requires large heatsink)0.3W (Assuming good P-FET)
Gate/Base Drive ComplexitySimple (Direct from 3.3V/5V pin)Simple (Needs base resistor)Complex (Requires NPN level shifter or dedicated gate driver IC)
MCU Pin SafetyHigh (Load ground switched)HighLow (Risk of exposing MCU pin to V_MOTOR voltage)

The TIP120 is a legacy component. Its Darlington architecture results in a massive collector-emitter saturation voltage (Vce(sat)) of roughly 2V. At 3A, that is 6W of pure waste heat. The IRLZ44N dissipates less than 0.2W under the same conditions. High-side P-MOSFET switching is necessary only if the load must remain grounded at all times (e.g., automotive chassis-grounded lights), but it requires an NPN transistor or dedicated driver to pull the P-FET gate low relative to the high-side supply voltage, risking the microcontroller pin if the level-shifter fails.

Failure Modes: What Breaks at the Extremes?

Every topology has specific single-point failures. Designing for the extremes ensures a component failure doesn't cascade into destroying your microcontroller or starting a fire.

Safety Caveat: When testing failure modes, always use a current-limited bench power supply set to 120% of your motor's stall current. Never rely on the microcontroller's USB power to supply the motor rail.
  • Open Gate (Missing R2 Pulldown): During ESP32 or Arduino boot, GPIO pins are high-impedance (floating) for several milliseconds. Without R2 pulling the gate to ground, ambient EMI can partially turn on the MOSFET. It enters the linear (ohmic) region, Rds(on) spikes to several ohms, and the MOSFET will thermally runaway and melt in seconds. Fix: Never omit the 10kΩ pulldown.
  • Short Gate-to-Source: The MOSFET is permanently held off. The motor will not spin. The microcontroller pin will output PWM into a dead short through R1, but the 100Ω resistor limits the current to ~33mA (at 3.3V), keeping the MCU safe.
  • Short Drain-to-Source: The motor receives 100% duty cycle continuously, bypassing PWM control. If the motor stalls, it draws locked-rotor current (often 5x to 10x running current), which can melt breadboard wires or trigger the power supply's overcurrent protection.
  • Missing Flyback Diode (D1): When the MOSFET turns off, the motor's collapsing magnetic field generates a massive inductive voltage spike (V = L × di/dt). This spike can easily exceed 60V, punching through the MOSFET's drain-source junction (avalanche breakdown) and coupling back into the microcontroller's ground plane via parasitic inductance, instantly bricking the ESP32. Fix: Place D1 as physically close to the motor terminals as possible.

Step-by-Step Breadboard Testing & Verification

Do not plug your microcontroller into the circuit until you have verified the power stage independently. Follow this sequence to validate the hardware.

  1. Wire the Power Stage Only: Connect Q1, R1, R2, D1, and the motor to your 12V bench supply and breadboard ground. Leave the MCU_PWM node disconnected from any microcontroller.
  2. Verify the Pulldown: Set your multimeter to continuity mode. Probe the GATE and SYS_GND. You should read approximately 10kΩ. If you read infinite resistance, R2 is missing or miswired.
  3. Test the Off-State: Power on the 12V supply. Measure the voltage between the motor's negative terminal (the DRAIN node) and SYS_GND. It should read exactly 12V (the supply voltage), confirming the MOSFET is fully off and blocking current.
  4. Manual Gate Drive Test: Use a jumper wire to briefly touch the MCU_PWM node to the 3.3V or 5V rail on your breadboard (or use a dedicated logic probe). The motor should spin up immediately.
  5. Measure Conduction Drop: While the motor is running via the manual jumper, measure the DC voltage between the DRAIN and SOURCE pins of the MOSFET. With the IRLZ44N fully enhanced, this should read less than 0.1V. If it reads >1V, your gate drive voltage is insufficient, or the MOSFET is not fully turning on.
  6. Check Flyback Clamping: If you have an oscilloscope, probe the DRAIN node. Disconnect the jumper wire to turn off the motor. You should see the voltage spike clamp cleanly at roughly 12.6V (12V supply + 0.6V Schottky forward voltage). If it rings to 30V+, your diode is too slow or wired backward.
  7. Integrate Microcontroller: Once verified, connect the MCU_PWM node to your ESP32 or Arduino. Ensure you configure the PWM frequency correctly; the Espressif LEDC PWM API defaults to 5kHz, which is ideal for most DC motors to avoid audible whining while keeping switching losses low.

For Arduino users configuring the standard analogWrite() function, remember that the default PWM frequency on pins 5 and 6 is roughly 980Hz, while other PWM pins run at 490Hz. This is generally acceptable for small motors, but if you experience excessive MOSFET heating at these low frequencies with highly inductive loads, consider using the TimerOne library to push the frequency above 4kHz.