RGB LED Problem

I recently bought an RGB LED from radioshack and am having problems getting it to light up with my Duemilanove. Here are the specs:

FW current: 30mA (green/blue), 50mA (red)
FW supply: 3.5V typical, 4.0V max (green/blue); 2.0V typical, 2.6V max (red)

Currently I can only get the red to light. I have what I believe to be the GND pin correct, and I have a 100ohm resistor in series with the +5V pin on the board, and upon touching it to the red pin, it lights, but when i then touch it to the other two (not at the same time, of course) nothing happens. Any help would be appreciated.

You need to know if you have a common anode or cathode LED, what you are doing will only work with a common cathode LED. For a common anode LED you need to connect the common to +ve and touch the other connectors to ground through the resistor.
Take the wire that lights up the red and connect that to the +ve. Touch the others to -ve through the resistor.

so reverse the polarity?

Edit: Hooked up 5V to the known pin, and the GND to the resistor then touched it to each pin, but none of them lit up.

Not quite, do what I said. The polarity is right otherwise it wouldn't light up.

i figured it out, its common anode and now i have the others working.
thanks

you will need 3 npn transistors... the anode goes to +5. then hook a resistor to each cathode. hook the other end of the resistors to the transistor collector. the transistor emitters go to a ground rail. the base of the transistor goes to a 1k ohm resisitor. the other end of that resistor goes to the digital pins.

you will need 3 npn transistors.

No you don't, you can drive an RGB LED directly off the pins.

you can drive an RGB LED directly off the pins.

no, I can't. the pins wouldn't be able to handle the amps when the colors are in parallel. or is there another way?

also, its common anode... so you need transistors...

its common anode... so you need transistors.

What's that supposed to mean?
You can drive common anode or common cathode RGB LEDs directly from the AVR without transistors, assuming the forward current of each LED doesn't exceed the AVR's maximum pin rating.

no, I can't. the pins wouldn't be able to handle the amps when the colors are in parallel.

Each colour is connected to a separate pin, the individual colours in an LED are not connected in parallel. Are you talking about more than one LED?
The specification:-
FW current: 30mA (green/blue), 50mA (red)
Is not what the LEDs will take it is what they could take. It depends on the value of resistor you use. If you are using 100R then that is a safe amount of current for a single pin. You need three pins to control one RGB LED.
See:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

If you connect the anode to 5v+ and the cathodes directly to the pins, set the pins as "LOW" (with digitalWrite) to tun them on, and "HIGH" for off. You can even drive them with PWM for dimming, just remember that what would normally be off is now on and vice versa. With PWM, 0 is full on and 255 is off.

If you connect the anode to 5v+ and the cathodes directly to the pins,

Then you have nowhere to put the current limiting resistors and you overload the arduino's pins. Thus permanently damaging it.

Ok, put the resistors between the cathodes and the pins, for one LED you can get away without them for basic prototyping

for one LED you can get away without them for basic prototyping

Read my lips .... NO NO NO NO NO

read my web page on why:-

http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

This has kind of confused me, but I am new. I also have a common anode RGB LED. I've got the common anode going to 5V on the arduino. Each of the other legs on the LED individually connect to a 220 ohm resistor and then to ground on the arduino. The LED lights up, and all 3 individual colors are visible. Is this correct in terms of not burning out the LED?

I have two confusions. First, in the wiring, what would I need to change to connect each color of the LED to pins 9, 10 and 11 to control the colors in the correct/safe way?

Second, when Grumpy_Mike said:
"Take the wire that lights up the red and connect that to the +ve. Touch the others to -ve through the resistor."

I don't know what that means.

thanks!

I got and copied this from the forum a while ago. I am not sure what thread it was from but it was fun to play with the values and just have fun.

/*
 * Cycles a three-LED common-anode package through the rainbow.
 *
 * Demonstrates fading multiple outputs, common-anode wiring, and the
 * use of functions to repeat similar tasks.
 *
 * Often, individual LEDs are wired in an "active high" configuration, so
 * a LOW output will cause the LED to turn off, and a HIGH output will
 * allow current to flow through the lamp.  Sometimes, packages of LEDs
 * will have a single ground pin for all of the diodes, called a "common
 * cathode."  These work on this same HIGH=ON, LOW=OFF principle.  You
 * just have to connect all of the positive legs of the diodes to their
 * respective output pins, and the common cathode goes to the ground.
 *
 * Other packages use the opposite wiring plan, offering a "common
 * anode."  You have to wire the shared pin to the +VDC source, and put
 * the resistors and diodes below the source.  To light the lamp, you set
 * the output LOW, and to extinguish the lamp, you set the output HIGH.
 * Signals which do useful things when given a low value are sometimes
 * called "active low."
 *
 * Wire a common-anode RGB LED package such that the anode connects to
 * the Arduino's +5V pin, and the other pins go to three PWM outputs to
 * allow for fading:  digital output pins 3, 5 and 6.  Don't forget to
 * put a resistor in series with every LED, or you'll burn it out!
 *
 * Ed Halley <ed@halley.cc>
 */

// Select which PWM-capable pins are to be used.
int redPin = 5;
int greenPin = 6;
int bluePin = 3;

// A function to fade UP an active-low or common-anode output.
// Optionally, specify a short delay value to slow the loop.
// (This would fade down an LED that was active high.)
//
void fadeUp(int pin, int d = 3)
{
  int i;
  for (i = 255; i >= 0; i--)
  {
    analogWrite(pin, i);
    delay(d);
  }
}

// A function to fade DOWN an active-low or common-anode output.
// Optionally, specify a short delay value to slow the loop.
// (This would fade up an LED that was active high.)
//
void fadeDown(int pin, int d = 3)
{
  int i;
  for (i = 0; i <= 255; i++)
  {
    analogWrite(pin, i);
    delay(d);
  }
}

// Set up our outputs, and give full high values so the
// LEDs start off.  Then fade in the blue LED.
//
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  analogWrite(redPin, 255);
  analogWrite(greenPin, 255);
  analogWrite(bluePin, 255);

  fadeUp(bluePin);
}

// The cycle of ramps will go through all of the primary
// and secondary hues in the RGB rainbow, and repeat.
//
void loop()
{
  fadeUp(greenPin);
  fadeDown(bluePin);
  fadeUp(redPin);
  fadeDown(greenPin);
  fadeUp(bluePin);
  fadeDown(redPin);
}