Exercise 2 - Pulse Width Modulation (PWM)

Pulse width modulation is a modulation technique used to encode a message into a pulsing signal. Even though this is a modulation technique for encoding information for transmission, it is widely used in controlling the brightness of an LED and the speed of a motor.

A PWM signal consists of two main components that define its behavior: frequency and duty cycle. The frequency determines how fast the PWM completes a cycle (i.e. 1000 Hz frequency would be 1000 cycles per second). The duty cycle describes the amount of on-time as a percentage of the total time of a cycle.

STEMTera™ Breadboard - Pulse Width Modulation

In digital electronics, when a signal is at 5V, we call this ON, and when a signal is at 0V, we call this OFF. From the above image, the first signal is shown as 10% duty cycle, which means its ON time is 10% of a cycle and its OFF time is 90% of a cycle. The second signal is 30% duty cycle because its ON time is 30% of a cycle and its OFF time is 70% of a cycle. A 100% duty cycle means the signal is ON all the time.

By varying the duty cycle of a signal, we can control the percentage of ON time for a circuit, hence indirectly control, for example, the brightness of an LED. 100% duty cycle will have the LED turned ON in full brightness and a 50% duty cycle will have the LED turned ON in half brightness.

Not every PIN on the STEMTera™ Breadboard can be used for PWM. Only PIN with a label ~ can perform as a PWM pin. PIN 3, 5, 6, 9, 10 and 11 only.

For this exercise we will be using the same circuit as the one we used for exercise 1. If you have already done exercise 1, just skip to Write and Upload section.

Schematic Title
STEMTera™ Breadboard - Exercise 2 - Pulse Width Modulation (PWM) Schematic Diagram
Part Title
RES_330Rx1
LED_REDx1
JUMPER_WIREx2
  1. Connect a JUMPER WIRE to GND and 33J.
  2. Connect a JUMPER WIRE to PIN3 and 38J.
  3. Connect a 330Ω RESISTOR to 34H and 38H.
  4. Connect the anode (longer) pin of the RED LED to 34G and cathode (shorter) pin to 33G.
Breadboard Title
STEMTera™ Breadboard - Exercise 2 - Pulse Width Modulation (PWM) Inkscape Breadboard Diagram