One of the first questions people new to Raspberry Pi or Arduino projects usually ask is “What is PWM?” or “What is Pulse Width Modulation?” In this quick tutorial we will quickly cover this topic and hopefully make some sense out of it.

In many of our articles we’ve talked about PWM conceptually, without going into any details… but you’ve likely seen us use it to dim an LED, control the speed of a motor, or to time addressable WS2812b LEDs.

Understanding PWM and Waveforms

Let’s start with a basic understanding of waveforms in general. The following drawing illustrates a zero volt waveform.  As you can see, it is just as you would expect. A flat line at the zero mark on the oscilloscope.

Next, lets look at a 10 volt DC waveform.  Not surprising, it is represented as a solid flat line at the 10v mark on the oscilloscope.

That should be pretty simple to understand. Either the voltage is zero, or it is 10 volts. Now let’s take our voltage and let’s turn it on and off. Roughly half the time the voltage will be zero, and the other half of the time the voltage will be 10 volts (again, all DC or direct current). What you will see represented on the oscilloscope is a square-wave. You’ll often here people talk about this type of wave as a 50% duty cycle waveform.

With 10v DC being applied to the circuit 50% of the time, we end up with something your probably already expecting – an average of 5v on the line. If we change the percentage to just 10%, we wind up with a 10% duty-cycle waveform and hence an average 1v on the line.

So what is PWM? That “pulsing” of a voltage for a percentage of the time is PWM or pulse width modulation!

You can buy a product called a function generator that will automatically create a PWM output for you at just about any voltage you desire. You can also buy a function generator for between $50 to $150 depending on what level of functionality you need. You can also build a basic PWM circuit for about $5-$10 in parts from Amazon!

PWM circuits are used in all sorts of application that you use every day. PWM is used to:

  • Dim the backlight on your TV or LCD monitor.
  • Control the motor speed on RC cars, planes, and boats.
  • Control the timing of LEDs in matrix displays and WS21812 LED strips.
  • many many more applications!

Leave a comment below if you know more places PWM is used in the real world!  We hope this article helped you understand “What is PWM?” and helps you make some awesome projects!


Leave a Reply