Intermediate Topic 20 of 50 Mobile, Embedded & IoT
PWM
Pulse patterns controlling power or brightness.
How it works
Pulse-width modulation encodes an analog level in a digital signal by switching a pin on and off rapidly and varying the duty cycle, the fraction of each period the signal is high. The average voltage seen by a slow load is proportional to the duty cycle, so a 25 percent duty cycle on a 5 volt signal averages 1.25 volts. Frequency determines the period, and hardware timers generate PWM without CPU involvement. Filtering PWM with an RC circuit yields a simple DAC.
Where it is used
Dimming LEDs, controlling DC motor speed, positioning hobby servos with pulse widths of 1 to 2 milliseconds, switching power supplies, audio tones and class-D amplifiers use PWM.
Common pitfall
Too low a frequency causes visible flicker or audible whine, and too high wastes switching losses or exceeds the driver's capability. Driving motors directly from pins can damage the controller; use transistors or H-bridges. PWM on mechanical relays is inappropriate. LED perceived brightness is nonlinear, so apply gamma correction. Match the frequency to the load.
Where it fits in the course
PWM is topic 20 of 50 in Mobile, Embedded & IoT, rated Intermediate. It follows ADC and DAC. The next topic is Serial Communication.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Mobile, Embedded & IoT quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Mobile, Embedded & IoT quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is PWM?
Where do people use PWM?
What is the most common mistake with PWM?
What should I learn before this topic?
How can I practice it?
Is PWM hard to learn?
How long does it take to learn PWM?
Which topics are related to PWM?
What should I study after PWM?
Related topics
- ADC and DAC (Mobile, Embedded & IoT)
- Serial Communication (Mobile, Embedded & IoT)
- Analog vs Digital Signals (Mobile, Embedded & IoT)
- Interrupts in Embedded Systems (Mobile, Embedded & IoT)