Embedded Systems Fundamentals · Interview question

Why can't you drive a motor directly from a PWM-capable GPIO pin?

A strong answer

Two reasons: current and inductive kickback. A GPIO pin can source only a few milliamps to maybe tens of milliamps, while a motor draws hundreds of milliamps to amps, the pin physically can't supply it and would brown out or be damaged. More dangerously, a motor is an inductive load: when you switch it off, its collapsing magnetic field generates a large reverse voltage spike (back-EMF) that will destroy the pin's output transistor without protection. So PWM from the MCU controls a driver, a MOSFET or BJT, an H-bridge, or a motor-driver IC, that switches the high-current path, with a flyback diode (or the driver's built-in protection) to clamp the inductive spike. The same applies to solenoids, relays, and high-power LEDs. The MCU provides the low-power control signal; the driver handles the power. Wiring a motor straight to a pin is a classic beginner mistake that fries the MCU.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

PWM

Fake an analog level with a digital pin: a fixed-frequency square wave whose duty cycle sets the average voltage, built on a timer and used for LEDs, motors, and servos.

More PWM questions

Browse all 472 interview questions
Why can't you drive a motor directly from a PWM-capable GPIO pin? | EmbeddedPrep.io