Introduction: Control RGB LED With Arduino and Processing.

I will today tell you how to control a RGB LED with help of Arduino and Processing language. This is my first instructable So, please let me know if I could anything improve and if you have any kind of questions leave them in the comment box, I would love to answer them. Simply you need the following items for this sweet little project.

  • 1 X RGB LED
  • Arduino
  • 8 X Connecting Wires
  • reflecting sheet ( optional)
  • 1 X Breadboard

Step 1:

These two are the codes of Arduino and Processing respectively. Main thing we are doing here is just controlling and RGB Led by clicking anf image named "color" and having extention ".jpg".

Step 2:

Now how does this program works:

The image we have uploaded using Processing is basis of this program. When we click on the image anywhere, the RGB value of that particular spot or pixel is sent to the Arduino and the RGB value of the led changes correspondingly and lights up in that color.

Step 3:

One tip here is that if you do not have an RGB led you and do the same by one green, red and blue led and connecting them in the same way the RGB led is to be joined. Mine here is common cathode but a common anode will also work.

Please feel free to ask any question I would love to answer them. And suggestions are also invited

hope you Enjoy it.

Thank You.

Step 4:

Comments

author
MsSweetSatisfaction (author)2015-01-12

Ooo the future is so pretty! Awesome job explaining the intricate bits of the build, this is a very cool gadget!

author

Thank you for your appreciation. It means a lot being a beginner :-)

author
austinkangaroo (author)2017-04-28

Hi! I am trying to do this project but i am running into a problem. I triple checked my wirings, and I downloaded both code files. Arduino and Processing are both fine with them, and color.jpeg opens up in the processing window, but I can't get the RGB to light up. Could you help me?

author
DivasG (author)austinkangaroo2017-04-28

Well, the processing code is alright because image opens. Now the problem could be in serial communication or maybe wiring as you said that you checked it 3 times. But, keep one thing in mind to check if your RGB led is a common anode or common cathode.

Check these two things and comment back if you still got a problem, then we'll solve it together.

author
austinkangaroo (author)DivasG2017-04-29

Hi! Thanks for replying!
So I believe the RGB Led is an anode. And I checked the wiring again and I believe its correct to your schematic.

author
DivasG (author)austinkangaroo2017-05-11

Hey, sorry for late reply, heavy college work going on these days. Okay so it seems that mine was Common cathode LED so, it turns out that your anode should be connected to +5V from arduino. Check this and if it still does not work then send me the schematic of the connections you made.

This is a great site to make circuit/schematics online.

https://circuits.io/

author
DivasG (author)DivasG2017-05-11

And one more thing that yours is common anode so our code will change we have to send the value 255-(the value from pixel) to each "R","G" and "B" pins.

See this clearly. We have a function named "outputColour" and its like this:

void outputColour(int red, int green, int blue) {

analogWrite(redPin, red);

analogWrite(bluePin, blue);

analogWrite(greenPin, green);

}

okay now here we have to change the scenario a little bit. As you can see it's sending values ranging from 0-255 which is for common cathode as the three RGB legs need to have +ve voltage to glow but, in common anode, we need to first connect our Led's anode to +5V from Arduino and change the function "outputColour" like this:

void outputColour(int red, int green, int blue) {

analogWrite(redPin, 255-red);

analogWrite(bluePin, 255-blue);

analogWrite(greenPin, 255-green);

}

Here what happens is suppose the colour value from the pixel of pic is of green i.e. (RGB = 0, 255, 0) okay. Now when we have to send this value to the led via our "outputColour" function we need to change it that is why because it needs 0, -ve values to glow.

So, its 0, 255, 0 after going to the function "outputColour" it will be

255-red = 255-0 = 255

255-green = 255-255 = 0

255-blue = 255-0 = 255

it reverses the values so now red and blue will be dim and green will glow.

I hope you get it. just change the outputColour function as I have told above and it will start working.

If you still don't get it or it won't work or it works and you still need more clarification on this. FEEL FREE TO POST ANOTHER COMMENT.

a bit long comment this on is.

Always happy to help:)

author
KaranB18 (author)2016-03-25

Cool one buddy....

author
DivasG (author)KaranB182016-03-25

Thank you

About This Instructable

2,611views

24favorites

Bio: I am a student of Electronics and Communication Engineering. Who loves Travelling, Nature and above all ELECTRONICS and SOLDERING :p. Want to make a breakthrough ... More »
More by DivasG:Ultra-Portable Led LampControl LED brightness with Remote and ArduinoControl RGB LED with arduino and Processing.
Add instructable to: