Shop OBEX P1 Docs P2 Docs Learn Events
Multi Color LED Question — Parallax Forums

Multi Color LED Question

NWCCTVNWCCTV Posts: 3,629
edited 2013-09-29 15:00 in General Discussion
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?
«1

Comments

  • Desy2820Desy2820 Posts: 138
    edited 2013-09-27 18:18
    Andy,

    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-27 18:30
    Prop BOE board has both 3.3V and 5V. The Datasheet shows the Green and Blue need at least 3.5V and Red needs 2V.

    So if I want to mix the colors then the resistors go to each pin, correct? Thanks for the help.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-09-27 18:34
    You will have to use 5 volts because of the forward voltage of the green and blue LEDs. Try a 120 ohm resistor, that gives about 1/2 the maximum current through the red LED (the one with the lowest voltage). If this resistor gives enough brightness for you with the blue and green then no need for separate current limiting resistors.


    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-27 18:50
    So a resistor at each pin or just one between Common Anode and 5V?
  • Desy2820Desy2820 Posts: 138
    edited 2013-09-27 18:55
    Three resistors, one at each pin, but you may need to expirement with the values to get the brightness you want. Since each LED has a slightly different forward voltage, it will affect how bright they appear to be. It looks like your min value should be 150 ohms though.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-09-27 18:58
    just one between Common Anode and 5V?

    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).
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-27 19:24
    OK. I will play around with different values to see what works best. I will post my results as others may find it useful since these are the multi color LED's that come in the kits that the Shack is clearing out for $6.00.
  • FranklinFranklin Posts: 4,747
    edited 2013-09-27 20:25
    When I pick resistors for this I power up all three LEDs and adjust the resistors until I have as close to white light I can get. That will allow you to pick different colors using fairly consistent PWM values.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-09-28 09:31
    So, you guys are all advocating tying a "Prop" pin to 5V, right?

    Irrespective of LEDs, you're good with a "Prop" pin being connected to 5V via a resistor?
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-09-28 10:04
    I think the recommended value, if the Propeller is connected through a resistor only, is at least 3300 ohms. In this case though, there is also an LED voltage drop of 3 to 3.5 volts, so no problem.

    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
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-09-28 10:20
    I would go with 3 transistors - probably 3 more than most people want to commit to any "project".

    IMG_1677.jpg
    421 x 335 - 19K
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-28 10:25
    So, you guys are all advocating tying a "Prop" pin to 5V, right?
    i think what they are saying is to run 5V to Common Anode and resistors to each prop pin.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-09-28 10:26
    NWCCTV wrote: »
    i think what they are saying is to run 5V to Common Anode and resistors to each prop pin.

    Same difference.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 10:50
    PJ Allen wrote: »
    So, you guys are all advocating tying a "Prop" pin to 5V, right?

    Irrespective of LEDs, you're good with a "Prop" pin being connected to 5V via a resistor?

    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.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-09-28 10:58
    For just driving LEDs, one resistor for each LED is the better way. This allows you to adjust the current (and therefore the brightness) individually for each LED.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2013-09-28 11:06
    If the green and blue leds drop 3.5V the resistor will have to drop 1.5V (5 – 3.5V) at the desired current so 150 ohms should result in 10mA. If the red led drops 2V a 150 ohm resistor will have to drop 3V (5 – 2V) resulting in a current of 20mA. This will create a large difference in the intensity of the red led compared to that of the green and blue leds. Better to use separate resistors for each. Try various resistor values to get matched intensities. You will probably find the red led needs less current than the green and blue leds to look equally bright. Also allows you to light more than one led at a time if needed at some point.

    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.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 11:23
    RGB LEDs has become a lot less expensive and easier to use lately.

    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.
  • ercoerco Posts: 20,256
    edited 2013-09-28 12:12
    Andy: I'm guessing these tricolors came out of the Shack LED assortment? :)
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2013-09-28 14:58
    I think this whole question calls for a bit of simplicity.

    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.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-09-28 15:30
    Because the propeller pin outputs 3.3V limited to 40mA of current.

    40 mA is the "max. allowable current per I/O pin", I don't think the Propeller will limit this on its own.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 15:57
    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.

    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).

    That said, I highly recommend going with a diffused common cathode RGB LED.

    Also my favorite when using a single RGB LED though I use resistors on all anodes.

    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.

    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.

    . . . 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.

    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-28 16:27
    Andy: I'm guessing these tricolors came out of the Shack LED assortment?
    Yes, They did. At $6.00 each I bought two from two separate stores. If there would have been more I would have bought more. Just the tri color LED's alone are more than $3.00 each!!!
    That said, I highly recommend going with a diffused common cathode RGB LED.
    I bought these from the Shacks clearance so I want to work with what I have, not purchase any more.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 16:31
    Andy, Be aware a deal at the Shack isn't necessarily a deal. LEDs cost much less from online sources.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-28 16:49
    @Duane, I understand this. However, even if I were to shop on EBay I think the total would be close to about $15.00 or so, what do you think, erco?
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2013-09-28 16:50
    Andy,

    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).
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2013-09-28 16:54
    @Duane,

    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-28 17:06
    Using the resistor values that Duane recommended the LED is actually brighter running on 3.3V instead of the 5V.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-09-28 17:45
    OK, I am having a brain lapse here. What command do I use in Spin to blink the LED? I was using Pause but it is called in timing and there is a time limit. I just want to blink indefinitely.
    OBJ
    pin : "Input Output Pins"
    time : "Timing"
    PUB Blink
    repeat
    pin.Low(0)
    time.Pause(100)
    pin.High(0)
    time.Pause(100)
    pin.Low(1)
    time.Pause(100)
    pin.High(1)
    time.Pause(100)
    pin.Low(2)
    time.Pause(100)
    pin.High(2)
    time.Pause(100)
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 17:52
    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).
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-28 17:59
    NWCCTV wrote: »
    OK, I am having a brain lapse here. What command do I use in Spin to blink the LED? I was using Pause but it is called in timing and there is a time limit. I just want to blink indefinitely.

    Everything under "repeat" needs to be indented for the repeat to effect it.
    PUB Main
      dira[0] := 1
      repeat
        outa[0] := 1
        waitcnt(clkfreq / 2 + cnt)
        outa[0] := 0
        waitcnt(clkfreq / 2 + cnt)
    

    The above should blink a LED half second on half second off (not exact though).
Sign In or Register to comment.