Now that you've had a chance to play with changing the brightness of an LED, we can use a tri-color, RGB (red, green, blue) LED to mix colors! We accomplish this by changing the brightness of the individual colors (red, green, and blue).

Build one of the circuits below (depending on which type of RGB LED you have), and write a program that changes the LED to various colors, such as orange, violet, cyan, yellow, etc.

Note that the RGB LEDs can come in 2 different forms: common cathode and common anode. Here is an image from a datasheet showing how the pins are often connected for common cathode and common anode (you might have to test the colors; sometimes green and blue are swapped):


If you have a common cathode RGB LED (such as the one from SparkFun or the one used in the simulator), build the circuit below. Common cathode means that the individual RGB components of the LED have all their negative pins connected, and you control the positive pins. When using PWM, 0 means "off" and 255 means "full brightness."

If you have a common anode RGB LED (such as the one from Adafruit), build the circuit below. Common anode means that the individual RGB components of the LED have all their positive pins connected, and you control the negative pins. When using PWM, 0 means "full brightness" and 255 means "off."