| Raspberry Pi CM5 IoT In C - - PWM Using GPIO5 |
| Written by Harry Fairhead | |||||||||
| Monday, 12 May 2025 | |||||||||
Page 5 of 5
What Else Can You Use PWM For?PWM lines are incredibly versatile and it is always worth asking the question "could I use PWM?" when you are considering almost any problem. The LED example shows how you can use PWM as a power controller. You can extend this idea to a computer-controlled switch-mode power supply. All you need is a capacitor to smooth out the voltage and perhaps a transformer to change the voltage. You can also use PWM to control the speed of a DC motor and if you add a simple bridge circuit you can control its direction and speed.
The amount of power delivered to a device by a pulse train is proportional to the duty cycle. A pulse train that has a 50% duty cycle is delivering current to the load only 50% of the time and this is irrespective of the pulse repetition rate. So the duty cycle controls the power, but the period still matters in many situations because you want to avoid any flashing or other effects. A higher frequency smooths out the power flow at any duty cycle. With a sufficiently fast period you can also use PWM as a digital to analog converter. Simply add a low-pass filter to remove the pulsing and you have a steady voltage proportional to the duty cycle. This can be used to create an audio signal if the clock is fast enough. Finally, you can use a PWM signal as a modulated carrier for data communications. For example, most infrared controllers make use of a 38kHz carrier, which is roughly a 26µs pulse. This is switched on and off for 1ms and this is well within the range that the PWM can manage. So all you have to do is replace the red LED in the previous circuit with an infrared LED and you have the start of a remote control, or data transmission, link.
Summary
Raspberry Pi Compute Module 5
|
Jules Coding Agent Upgraded 22/10/2025 New options are now available for Jules, Google's coding Agent - a CLI and an API. |
AI Champion Ship Now Open 07/11/2025 The AI Champion Ship is now underway, with a month to go before entries close. The organizers describe it as a global competition for builders, dreamers, and tinkerers who want to push AI beyond the o [ ... ] |
More News
|
Comments
or email your comment to: comments@i-programmer.info


