Strange RGB LED

I am getting started with a Keyes LED RGB 140C05. It is an common cathode RGB LED with 331 ohm resistors.

I am using analogWrite to drive the pins, and I cannot reproduce colors. The colors I do reproduce are unexpected. Here is my code:

int redpin = 6; 
int bluepin =5; 
int greenpin =3;

void setup() {

  pinMode(redpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  
  analogWrite(greenpin,255);
  analogWrite(redpin,255);
  analogWrite(bluepin,255);

}
void loop() {}

These are my results:
r g b color color w/o ground
255 0 0 off off
0 255 0 white pink
0 0 255 off off

0 255 255 blue/green blue
255 0 255 off off
255 255 0 yellow red

255 255 255 green off
0 0 0 off off

  • green has to be 'on' for others to work
  • red & blue only display up to value of green, but full on when no ground

I have tried to search for similar problems, and switch around the wires, but I find it difficult to describe the problem and the IC looks correctly labeled. Any tips? I feel like I must be overlooking something very simple.

Have you heard of the WS2801 ?

Hi, sounds to me like its the result of a manufacturing error. I suspect it is in fact a common-anode led and the common has been labelled as green and green labelled as common. Red and blue labels are also swapped.

So... connect "green" to 5V and "common/ground" to the Arduino output. Swap your red and blue connections. An analogWrite value of 0 will turn a colour full on and 255 full off.

Paul

PS. The usual names of those colours: "blue/green" is called cyan and "pink" is magenta.

PaulRB,

That was indeed the problem. Kind of nuts. This is the result of having the wrong LED and having it hooked up wrong? I am expecting to order a lot of 50-100 for a project. Is this type of thing common?

PS Thank you so much =] !! :slight_smile:

Would the 4-pin LED having been soldered in to the PCB backward account for this?

terdmcgurd:
That was indeed the problem. Kind of nuts. This is the result of having the wrong LED and having it hooked up wrong? I am expecting to order a lot of 50-100 for a project. Is this type of thing common?

If you buy cheap stuff from China, yes :slight_smile:

A colleague bought an iPhone car charger off ebay. Being a curious sort, he opened it up to see what regulation was used. There was none! 12V was wired direct from input to output.

Buying in volume seems to provide an opportunity to hide wrong spec/faulty parts, in some cases I've heard of 50% failure rates.