Shop OBEX P1 Docs P2 Docs Learn Events
Red/Green Bi-state LED — Parallax Forums

Red/Green Bi-state LED

ZootZoot Posts: 2,227
edited 2006-05-04 15:31 in BASIC Stamp
I have some red/green bi-state LEDs (two leads). The forward voltage req. on the LEDs is about 2.4 volts.

Would the following work?

- hook up one lead of the LED to Vdd with a resistor so I get about 2.5 volts on that lead
- hook up the other lead of the LED (through a resistor) to a PIN of my BS2p40
- a HIGH state on the PIN would light the LED red (5v on LED lead to PIN, 2.5v on the other = ~2.3 volt difference)
- a LOW state on the PIN would light the LED green (0v on LED lead to PIN, 2.5v on the other = ~2.3 volt going the other way)

I saw something akin to this in the documentation for the PWMPal, but I want to do this with only 1 pin.

Also, Is there a way to "float" the pin to turn the LED off?

Could you also do the same thing if you're hooking up the LED(s) to a shift register (to save pins)?

Thanks in advance.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

Comments

  • Grant_OGrant_O Posts: 36
    edited 2006-04-19 22:52
    That’s a really good question! Can you shift polarity using only one pin? hmm... I might give it a try later on tonight.

    "Is there a way to "float" the pin to turn the LED off?"

    Well if you are able to actually make this work (Red = High, Green = Low) then you could use a capacitor to remove the voltage spikes and PWM it at 2.5v and then yea that should work.
  • BeanBean Posts: 8,129
    edited 2006-04-19 23:50
    You will need to use two resistors to get the 2.5V. One from Vdd(+5V) to the LED-Pin1 and one from LED-Pin1 to Vss(Gnd). Try 220 Ohms resistors.
    Connect LED-Pin2 to your I/O pin (no resistor here).
    Use INPUT to make the pin "float" that will turn the LED OFF.

    One downside of this method is that it uses power whether the LED is on or not. About 11mA if you use 220 Ohms resistors.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
    Product web site: www.sxvm.com

    Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-04-20 00:28
    Bean is right.
    The attached document shows how, and also has formulae to calculate
    the resistor and total current if one led is on, based on led forward voltage
    and led forward current.

    regards peter
  • ZootZoot Posts: 2,227
    edited 2006-04-20 04:50
    Thanks so much. I am so psyched to set up my mini LED display.... It also seems that if you're using a shift register to drive your LEDs, you *would* be limited to Red or Green -- no off.

    In the Stamp Reference Manual under INPUT and under the discussion of the PIN symbol, I don't see documentation about IN pins "floating", unless I missed it. What's the technical term for a floating pin anyway?
    Bean said...
    One downside of this method is that it uses power whether the LED is on or not. About 11mA if you use 220 Ohms resistors.

    That power's coming across the voltage divider, tho', right? So I'm not sucking it off my Stamp? Yeah, that could be a drag with a lot of LEDs in something smaller. Fortunately, this particular project has a very hefty power supply.

    Sort of related question -- if I use some extra pins on a PWMPal, can those pins float to achieve an "off" LED using this kind of voltage divider setup? I don't think you could do it with duty cycles and pulse widths (like getting an orange color).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    Post Edited (Zoot) : 4/20/2006 4:56:08 AM GMT
  • Tom WalkerTom Walker Posts: 509
    edited 2006-04-20 14:18
    "Thanks so much. I am so psyched to set up my mini LED display.... It also seems that if you're using a shift register to drive your LEDs, you *would* be limited to Red or Green -- no off."

    Unless you use another shift register into a tri-state buffer to create your "floating" condition. Adds some complexity and timing issues, though...

    Sounds fun!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...

    Post Edited (Tom Walker) : 4/20/2006 2:22:02 PM GMT
  • ZootZoot Posts: 2,227
    edited 2006-04-20 15:51
    Hey, that's a good idea. But at that point I think I would use some of the I2C driver chips I've seen that let you run banks of 16 LEDs with PWM using just two pins and up to 8 addressable drivers. All the really cool ones are surface mount only, though, and I'm not sure I want to go there until I get thinner fingers and a thinner soldering iron smile.gif. See link below for spec sheet.

    For this particular project, I'm using 4 bi-state LEDs for status indicators and aside from the cool colors, I wanted more possible combinations out of the display -- 3 x 3 x 3 x 3 = 81 combos for 4 LEDs or 3 x 3 x 3 for 27 combos if I need a pin back.

    www.semiconductors.philips.com/pip/PCA9532_3.html

    (They're $1.65 at DigiKey)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-04 08:57
    I came across this one:
    http://www.elecdesign.com/Articles/Index.cfm?ArticleID=1683
    schematic:
    http://www.elecdesign.com/Files/29/1683/Figure_01.gif

    This does not create a fixed 2.5V point, the·standby current (both leds off)
    is therefore approx. 2.7 mA

    Edit: I just tried it with 2 standard 3mm leds and all resistors 1k.
    Works great.

    regards peter
    ·

    Post Edited (Peter Verkaik) : 5/4/2006 9:37:24 AM GMT
  • ZootZoot Posts: 2,227
    edited 2006-05-04 14:58
    Yeah, I did almost exactly the same thing with 4 leds over the weekend. It's very very cool.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-04 15:31
    On the javelin with background pwm I can even have both leds on,
    so 1 pin for 4 states. The SX can do that too.
    regards peter
Sign In or Register to comment.