RGB LED

An RGB LED is basically the same as three LEDs in one package: red, green, and blue. They share a common pin that goes to ground (GND), so it has four pins total.

The RGB LED

The LONGEST pin is the one that goes to ground.

Wiring

Don’t unwire your regular LED to set this up! There’s plenty of pins for both.

To wire it up, connect each leg of the three non-ground RGB LED legs to an individual output pin. Don’t forget a 220 Ohm resistor!

Example wiring diagram

Set up each of these pins using pinMode in setup and choose any mix of colors you want using analogWrite to each pin. Play with different analogWrite values to see what colors you can create!

See this lesson for Adafruit for more details on setting up an RGB LED. This is an exercise for you to test what you’ve learned!

Bonus exercise: Can you make the RGB LED color slowly shift over time? If you need help, take a look at this example code for reference.

Wrap up

This concludes the first workshop! Leave your hardware as-is at your table and remember where you sat.

< Previous: Dimming LEDs · Next: Button >


Edit this page.

This content is licensed under CC BY-NC-SA.