User Manual

54
Lesson 5 RGB LED
Introduction
Prev iously we'v e used the PWM technology to control an LED brighten and dim. In this lesson,
we will use it to control an RGB LED to flash various kinds of colors.
Components
- 1 * Raspberry Pi
- 1 * Breadboard
- 1 * RGB LED
- 3 * Resistor (220Ω)
- Sev eral jumper w ires
Principle
In this experiment, we will use a RGB. For details of RGB, please refer to the introduction of
RGB LED in Components Introduction.
The three primary colors of the RGB LED can be mixed into various colors by brightness. The
brightness of LED can be adjusted with PWM. Raspberry Pi has only one channel for hardware
PWM output, but it needs three channels to control the RGB LED, which means it is difficult to
control the RGB LED w ith the hardware PWM of Raspberry Pi. Fortunately, the softPwm library
simulates PWM (softPwm) by programming. You only need to include the header file
softPwm.h (for C language users), and then call the API it provides to easily control the RGB
LED by multi-channel PWM output, so as to display all kinds of color.
Experimental Procedures
SunFounder