Introduction: How to Use an RGB LED - Arduino Tutorial

Picture of How to Use an RGB LED - Arduino Tutorial

An RGB LED has 4 pins, one for each color (Red, Green, Blue) and a common cathode. It has tree different color-emitting diodes that can be combined to create all sorts of color! Any color is possible depending on how bright each diode is.

Watch the following video:

In this tutorial you will learn how to use an RGB LED with Arduino and create unique color combinations.

So, let's get started!

Step 1: What You Will Need

Picture of What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • RGB LED
  • 3x 330Ohm resistors

Step 2: The Circuit

Picture of The Circuit

The connections are pretty easy, see the image above with the breadboard circuit schematic.

Step 3: The Code

Here's the code, embedded using codebender!

We will use code from SparkFun Inventor's Kit - SIK Guide, Example sketch 03. This is the best sketch to learn how an RGB LED works. The code is pretty self-explanatory, and the comments do a better job than me explaining how it works.

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino board with this sketch. And that's it, you've programmed yourArduino with the RGB LED sketch!

Step 4: Well Done!

Picture of Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use an RGB LED with Arduino.

Comments

kavish laxkar (author)2016-05-12

i have common anode(+)...will it work?

Instead of attaching it to the negative(-) you need to attach them to the positive(+) 5v or the light won't turn on. This is what I've found out

kavish laxkar (author)2016-05-12

cool

WhittlinThom made it! (author)2015-12-11

This was nice and easy. I was happy when the RGB LED lit up. I'm a 72 year old man just trying Arduino to keep from going senile. I really need help understanding Arduino some times. If there's anyone in the USA willing too tutor me for fun please email me at usthom2000@yahoo.com or on Facebook. Thank you, Thom Mulford

WhittlinThom (author)2015-11-25

Hi, I might be wrong but your pictorial diagram looks to me like it will only lite the green light on the blue wire. Am I mistaken?

JRV31 (author)2015-06-29

Make sure you use common cathode LEDs with this instructable. Adafruit sells common anode RGB LEDs, Sparkfun sells both.

zwalker3 (author)JRV312015-08-20

how do i tell or know its a common cathode compaired to (what are the other comparisions)?

JRV31 (author)zwalker32015-08-28

They look the same, you need to read the datasheet or the part description before buying.

elettrospillo (author)2015-08-05

Hello, I am new in this channel I need help to manage more possible LED and independent. Could you help me?

tomatoskins (author)2015-06-25

I love RGB LEDs! This is great!

About This Instructable

13,047views

307favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
Add instructable to: