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.
Embedded Systems Fundamentals · Interview question
Why can't you drive a motor directly from a PWM-capable GPIO pin?
A strong answer
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
What is PWM and how does it produce an "analog" output from a digital pin?How is PWM generated using a timer?What's the tradeoff between PWM frequency and duty-cycle resolution?How does PWM control a hobby servo, and how is that different from LED dimming?What is dead-time in a complementary PWM pair, and why does an H-bridge need it?Your PWM-controlled LED looks steady to the eye but flickers badly on camera video. What's going on and how do you fix it?
Browse all 472 interview questions