A standard hobby servo is commanded by pulse width, not by average voltage. It expects a pulse roughly every 20 ms (50 Hz) whose high-time encodes the target angle, typically about 1 ms for one extreme, 1.5 ms for center, and 2 ms for the other extreme, and the servo's internal controller drives its motor until its position matches the commanded pulse width. So the information is in the duration of the high pulse, and the duty cycle is low (1-2 ms out of 20 ms) and not meant to be averaged. LED dimming is the opposite use of PWM: there the average is the signal, duty cycle directly equals perceived brightness, and you run at a high frequency (hundreds of Hz or more) specifically so the eye integrates it into a steady level with no flicker, with the exact frequency unimportant as long as it's above the flicker threshold. So both use a timer's PWM, but the servo cares about absolute pulse width at a fixed 50 Hz, while the LED cares about the averaged duty at an arbitrary high frequency.
Embedded Systems Fundamentals · Interview question
How does PWM control a hobby servo, and how is that different from LED dimming?
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?Why can't you drive a motor directly from a PWM-capable GPIO pin?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