User Manual
Table Of Contents
VMP502
V. 02 – 25/10/2019 12 ©Velleman nv
Python Programming
6.4 Breathing LED
We will gradually increase and decrease the luminance of an LED with PWM.
Required Hardware
• 1 x Raspberry Pi
®
• 1 x breadboard
• 1 x LED
• 1 x 220 Ω resistor
• jumper wires as needed
Pulse Width Modulation – or PWM – is a technique for getting analogue results with digital means. Digital
control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate
voltages between full on (3.3 V) and off (0 V) by changing the portion of the time the signal spends on versus
the time that the signal spends off. The duration of the “on time” is called the pulse width. To get varying
analogue values, you change – or modulate – that pulse width. If you repeat this on-off pattern fast enough
with an LED, the result is as if the signal is a steady voltage between 0 and 3.3 V controlling the brightness of
the LED.
A duty cycle is the percentage of one period in which a signal is active. A period is a time it takes for a signal to
complete an on-off cycle. As a formula, a duty cycle may be expressed as:










