Variable LED colors

Okay so I recently purchased

http://www.lctech-inc.com/Hardware/Detail.aspx?id=5939ff03-520f-4529-9806-c33ddc12f684

and I am curious if it is possible to output a value for example RGB(20,50,221)?

I've looked everywhere and nothing specifically answers the question or how I would go about doing it.

Thanks!

For those modules you would need to use 3 PWM pins to control the color.

That is a simple RGB LED.

Connect Gnd to Gnd, and the other three pins to PWM capable pins. So if you connect R/G/B to pins 9/10/11, you could get that with
analogWrite(9,20);
analogWrite(10,50);
analogWrite(11,221);

Note that:

  1. RGB LEDs give miserable color rendition even if you do everything right. There are some kinds of colors they're great at, while other colors just never look right.
  2. The response curves are not linear, so if you actually want to match RGB values, you'll have to do some sort of correction. (This is an issue on all RGB leds).

Connect the GND pin to the Arduino GND
Connect Arduino pin 3 -> R
Connect Arduino pin 5 -> G
Connect Arduino pin 6 -> B
And the code:-

void setup() {
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);

// write RGB 20, 50 211
analogWrite(3,20);
analogWrite(5,50);
analogWrite(6,211);
}

void loop(){
// do nothing
}

The RGB LED's actually are not bad at all for colors, you need to use a diffuser(plastic from a milk container). I even dipped one in a short tube of hot glue to use for a project, when the glue completely cooled, the colors were more accurate, even orange!. And yellow was actually yellow!

Use Windows Paint and edit the colors, it'll show you the RGB values.

I've seen a RGB library around somewhere that uses that command structure like RGB(r,g,b).