Now that you have your circuit ready, let's run our example code. Our example will light up the LED and make it alternate different colors. Here are the steps to follow:
- Run the code in the chapter08/rgbled_common_cathode.py file and you should observe the RGB LED cycling colors. Take note of the first three colors, which should be red, green, and then blue.
To use a common anode RGB LED, it needs to be wired differently than shown in Figure 8.2—the common anode leg must go to the +3.3V pin on your Raspberry Pi, while the GPIO connections remain the same. The other change is in code where we need to invert the PWM signals—you will find a file called rgbled_common_anode.py in the chapter08 folder with the differences commented.
- If your first three colors are not red, green, and then blue, your RGB LED may have its legs in a different order than the RGB LED's pictured in Figure 8.1 and the circuit...