Multi Color LED Question
NWCCTV
Posts: 3,629
I have a few of these LED's which are Common Anode. So I do not fry anything in the process, can someone explain how to connect to a Prop BOE board? What I want to do is just light Red if condition A exist, Green if condition B exist and Blue if condition C exist. I understand I can do more than that but for now this is all I need. I was thinking that the Common Anode would go to 5V and I could use 270 Ohm resistors from each color to prop Pin. But where do I ground them?
Comments
I'm sure you already figured this out, but ground would be supplied thru the prop itself. To light the respective LED, you simply make the pin's output low, iwhile leaving the others high. To turn it off, you could either make the pin an input (floating), or high.
You correct on the resistor placement, however, if only one color was ever on at any time, then you can just place one 270 ohm resistor between the common anode and positive power.
EDIT: Just caught something. Your post talked about connecting to 5V, but I thought the prop ran on 3V3. Double-check that, you may need to connect the anode to 3V3 instead of 5 volts. Hopefully another forumista will clarify this for us.
Hope this helped.
So if I want to mix the colors then the resistors go to each pin, correct? Thanks for the help.
edit: Actually, I'd probably go with a little higher ohms on the resistor, maybe 150 or more. No need to push the Prop pin too hard.
As long as only one is on at a time, and the blue LED lights up enough for you with a resistor sized for the red LED. Most modern LEDs will light up pretty bright with nowhere near their maximum allowable current. Just try it and see. Hook it up to 5 volts through a 150-200 ohm resistor and ground each of the cathodes one at a time. You can try two and three at the same time, just to see if they'll all light at once (probably not, with a single resistor).
Irrespective of LEDs, you're good with a "Prop" pin being connected to 5V via a resistor?
There is a big long thread about Propeller interfacing with other voltages
http://forums.parallax.com/showthread.php/85474-How-to-safely-interface-a-5v-signal-to-the-propeller
And an Application Note at Parallax Semiconductor
http://www.parallaxsemiconductor.com/an010
Same difference.
This has been bugging me.
I know how to deal with a 5V signal on an input (use a big resistor) but not for sinking current from a 5V power source I take that back; I do know. Use a transistor.
I rarely want just one RGB LED so I frequently use a '595 at 5V.
Edit: I just looked at PJ's schematic. I heartily concur with him.
One resistor for multiple LEDs usually won't work, unless they are all the same type, because of differing voltage drops.
One resistor for multiple LEDs all of the same type will work, but each additional LED that is lit will cause the brightness of all the LEDs to decrease.
Just to light plain old LEDs, I really don't see the need for transistors or other intermediate driver devices.
PJ Allen has a point about connecting a led/resistor between a prop pin and +5V. If the led should fail with a shorted condition you will be putting +5V on the pin through a very low value current limiting resistor. Pop goes the pin, and perhaps the prop itself. Not very likely to happen at low led currents, but always a possibility.
Here's Tom Crawfords RGB message board project. He's using TLC5916 chips to control the LEDs.
Here's my RGB array project. I'm using high power shift registers.
For even easier RGB fun you can use the daisy chainable chips.
Here's my award winning Mood Enhancing LED project. This uses WS-2801 chips (driver by JonnyMac).
Post #13 of the above mentioned project shows RGB LED Christmas lights purchased from CostCo.
There are also NeoPixels (WS-2812) which have the control chip embedded in the LED (driver again by JonnyMac).
The WS-2812 LEDs (which use the WS-2811 control chip internally) aren't too expensive if you buy 100 at a time. A strand of WS-2812 LEDs only requires one I/O pin to control.
If going with the common anode tri-color LED, you want a separate resistor for each of the three cathodes, preferably with the largest resistor on green, and two smaller resistors for blue/red. It isn't just about voltage drop, but also about the fact that the green LED is much more intense than blue or red (red is usually dimmest). In most of these RGB, leds, the green puts out disproportionately more light that the blue and the blue puts out more than the red. Add to the fact that green is in the middle of the human photosensitivity range, this green bias becomes even more pronounced. One advantage is you can use a 5V source.
That said, I highly recommend going with a diffused common cathode RGB LED. The reasons for this follow:
- You can connect each of the three anode pins (RGB) directly to propeller pins and connect the cathode to ground. No resistors, no transistors, no drivers, nothing!
Why?
Because the propeller pin outputs 3.3V limited to 40mA of current. Although higher than the rated 20mA, do you really care if the LED lasts 25000 hours instead of 50000? You are still far away from reaching the LED's thermal limit. The LEDs will run just fine and the voltage of 3.3V is close enough to the 3.4V drop of green/blue to the point that they will work. This is the simplest solution and it works great for me.
You can also add small resistors to between the pins and anodes if you really want. Remember the formula is R = (Vin - Vforwardled) / I) (I is usually 20). You will find that using this equation will give you either a negative or zero resistance for the blue/green leds and a very modest resistor value for the red one.
You can buy common cathode diffused LEDs on sparkfun in bulkpacks or from china really cheap on ebay.
That's my 2 cents.
40 mA is the "max. allowable current per I/O pin", I don't think the Propeller will limit this on its own.
We are more sensitive to green light but white light still looks white not green. I'm pretty sure we need just as much green light as we do blue and red in order for the light to look white.
With a 5V source, I use 100 ohm resistors on green and blue and 150 ohm on red since the red LED has a low voltage drop.
With the LEDs in the previously mentioned 8x8 arrays, these resistor values give about 20mA per LED (with a very nice looking white).
Also my favorite when using a single RGB LED though I use resistors on all anodes.
As RDL2004 just mentioned, the Propeller doesn't limit the current directly, you should use resistors to do so. The Propeller pins do have some internal resistance, enough to safely drive green and blue LEDs. Red LEDs would pull too much current to safely use without a resistor. I think it's best to use resistors for each color.
This is one of the problems of driving RGB LEDs with 3.3V, it's hard to know what the voltage drop across the resistor will be so it's hard to know what the resistor value should be.
I bought these from the Shacks clearance so I want to work with what I have, not purchase any more.
You can get RGB LEDs for $0.95 or 25 or $19.95 from sparkfun, or you can get 100 of them from china on ebay for $7.49 plus $1.00 shipping. (It may take a week or two).
Your resistor values seem reasonable - many of the RGBs have 2x the green output than red, and blue is usually about 30% more light output.
I haven't had any problems. Maybe someone could chine in, but I do think that the propeller pins limit to 40mA output. I started ditching the resistors when the parallax folks weren't using them on their boards w/ leds at an event. They told me that the 40mA limit on output was in the chip and that I can't burn out an LED from a prop pin.
Here's the thread I was thinking about. I thought one still had to worry about red LEDs unless both the anode and cathode are connected to the Prop (twice the resistance).
Everything under "repeat" needs to be indented for the repeat to effect it.
The above should blink a LED half second on half second off (not exact though).