Step 5: Pulse Width Modulation

The Arduino board is only capable of generating digital signals (HIGH and LOW), but analogWrite(); simulates the appearance of varying brightness between on and off using pulse width modulation (PWM). The LED flashes on and off very quickly, and your eye interprets a dimmer light. The ratio of time the LED spends on vs. off determines how bright or dim the LED appears.

Pulse width modulation (PWM) creates an oscillating digital signal, alternately driven high and low in a repeating pattern. Each high to low to high period of time is called a cycle.

  1. Click Start Simulation. You should see an oscillating digital signal on the oscilloscope like the animation above.
  2. Notice that for each cycle, the width of the HIGH and LOW portions of the graph are changing, hence the term pulse width modulation, or PWM for short.
  3. Identify the other digital pins on the Arduino Uno capable of PWM, marked with a ~: 3, 5, 6, 9, 10, and 11.
  4. Continue to the next step.