Pages: [1]   Go Down
Author Topic: How to make a mood light with rgb led  (Read 1774 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi i'm kind of a noob at arduino and i would like to make a mood light. I have an arduino duemilanove and an rgb led.
I tried this http://blog.bsoares.com.br/processing/controlling-rgb-led-with-arduino-and-processing but it didn't work as well as the video(colors are diferent, maybe it's not the same led).
Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 659
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately my knowledge of the Portuguese language is as good as my knowledge of Chinese smiley-wink

I do know that 4-pin RGB leds are sold with either a common Cathode or a common Anode.

Using the "wrong" one will result in the opposite of what you try to achieve.
Pointing at a white part of the window, which normally turns all colours on, will result in dimming the led. Pointing at green only will turn green off,  blue and red on, resulting in a pink colour.

If that's the case you can quite easily make it all right by changing the arduino sketch.

Code:
 r = color >> 16 & 0xFF;
  g = color >>  8 & 0xFF;
  b = color >>  0 & 0xFF;
 
  // Send values to analog pins
  analogWrite(PIN_RED, r);
  analogWrite(PIN_GREEN, g);
  analogWrite(PIN_BLUE, b);


Above is part of the code for the led the author used to control the different colours.
Changing it to the opposite using the code below should result in getting the colours the author wanted to show.

Code:
 r = color >> 16 & 0xFF;
  g = color >>  8 & 0xFF;
  b = color >>  0 & 0xFF;
  // change colours to the opposite here
  r = 255 - r;
  g = 255 - g;
  b = 255 - b;
  // Send values to analog pins
  analogWrite(PIN_RED, r);
  analogWrite(PIN_GREEN, g);
  analogWrite(PIN_BLUE, b);

I hope this will solve your problem.
« Last Edit: May 23, 2011, 06:40:15 pm by Simpson_Jr » Logged

Winter Park, Fl
Offline Offline
Full Member
***
Karma: 0
Posts: 103
I dabble with arduino, web design and other tech things, but I enjoy A/V and music as my career as an A/V Fabricator and owner of a home studio.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So what do you want to do?

Do you want it to be a standalone mood light of some sort? or do you want to be able to control the color like in the video? And i wouldn't worry about the colors being the same because most cameras distort colors horribly.

(BTW i am very new to Arduino as well but ill do my best to help)
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm looking for a better processing code to control the led and i think i hae the oposit of the led used in the tutorial, what it is called?
Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 659
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ouch, forgot to mention one part, my mistake, sorry...

The author did use a Common Cathode, connecting the common pin to ground.

In case of an Common Anode RGB-led you should connect the common pin to +5 volt (and change the code) as well.

In the tutorial he does mention the use of resistors, but for some reason he doesn't seem to use them in the pictures given. That could ruin Led/arduino.

With a resistor of ~220 ohm you should be able to determine what type your Led is.
Connect the common pin to ground, connect the resistor to +5volt on one side and a colour-pin on the other. If it lights up it's a common Cathode.

If it lights up when you change ground and +5Volts using this set-up it's a Common Anode.

Colours shown may indeed differ due to camera and Led. I've got a few 5mm leds and a few high power RGBs, but they're quite different in colour.

It should by the way also be possible to change the code in processing instead of the arduino sketch.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tested it i have a common Cathode. Thanks for the tip.
Logged

Pages: [1]   Go Up
Jump to: