PWM using an RGB LED
In the previous section, we observed the use of write_analog()
for PWM signal generation. The same principle can be employed to achieve different color intensities through an RGB LED. An RGB LED differs from the usual LED in multiple ways; the first difference is the number of pins; in a standard LED, two pins are provided, whereas an RGB LED has four pins. In Figure 9.10, an RGB LED is depicted. It is visible that an RGB LED has red, green, and blue pins, which indicate the colors, and a positive pin connects to the ground:
Figure 9.10 – An RGB LED (courtesy: https://en.wikipedia.org/wiki/Light-emitting_diode)
The most extended pin, as shown in Figure 9.10, indicates an anode. By providing the PWM signal, the LED will glow in various colors. Hence, an RGB LED is used in applications where several light hues are required from a single LED. As we have done in the case of handling the potentiometer and servo motor, we are now going...