# Bi-color LED on one pin...

Hey guys,
So, this may be a stupid question, but at 6am, I want a second opinion, LOL…

I’m working on a project where I’ve got three lines available to a control panel that needs to read multiple buttons, as well as light a bi-color LED in either of the two colors (it never needs to be off, FWIW).

I’ve got a handle on the buttons, I’m going to do the analog “multiplex” thing with appropriately selected resistors so that I can just feed V+ in from the Arduino, then the switches will connect their respective resistors between V+ and an analog input.

So that ties up two pins, one with V+, and one for the input. I think I have a way to get the LED working with the remaining pin, but just want to make sure I’m not doing something stupid.

My theory is (being 6am and half-functioning, I’ll gloss over the current-limiting resistors for now, and come back to the math once I’m sure the basic concept is valid) that I can use +3V as the supply voltage for the control panel, and then the LED will go between the 3V and a digital output.

If I set the output low, then the LED will see the +3V relative to the low output’s ground, and light up green.

If I set the output high (ie, +5V), then the LED sees the +3V relative to the high output’s +5V, for a potential of -2V compared to the low state, and would light up red.

Will this work, or am I missing something really stupid in my overtired state?

Andy

Yes that would work for the sort of bi-coloured LEDs with only two wires.

Of course the other way would be to have an LED with one end common and switch the other end through a transistor and the other end of the other LED direct.

Another way to do it is to take 2 resistors (one for the green, one for the red), one goes into the +, the other goes into the GND, and connect the other ends together. Connect one pin from the LED to that same connection where the resistors meet, and the other LED pin into the digital out/in of Arduino. When the Arduino pin is low, current will flow from the positive resistor into the Arduino pin, with the pin is high, current will flow from the Arduino pin to the GND resistor.

Always worked well for me.

-macgruber

Macgruber, this won't work in my situation, because it requires an additional pin. Because I'm limited to three lines to the control panel, I don't have any way to get a dedicated ground.

I already need the + and analog in for reading the buttons, which ties up two of my three lines. So I only have one other pin available to make the magic work; ie, I have my + and one control line available for the LED, so the only way to make it feasible is to make either the + or the control line be the "ground" for the LED.

ahh, I misunderstood your post. I thought you had a ground rail on the panel that you could use...

LOL, don't I wish. That'd make life soooo much easier. It's actually a handheld remote, and needs to connect via an existing cable run. Ah, the fun of challenges :-)

Check out http://www.neufeld.newton.ks.us/electronics/?p=151, which discusses driving a two-lead bicolor LED from a single pin using a resistor divider.

Also check out the circuit in the comment I left using two zener diodes to reduce the current used by the circuit. And also see the next post for a discussion on the dangers of driving an input pin at Vcc/2. All Arduino pins have a Schmitt trigger on them, though, so it might be safe.

Except that I'm driving an analog input pin, not a digital input, so Schmitt or not, it's moot :-)

And aref can be set to the lower voltage, so I'm not losing half the resolution.

you can do it with two pins if you are cleaver!

connect the switch circuit in parallel to the led, then you can alter the colour of the led by changing the polarity of the two wires. all you then need to do is rectify it before you feed it back in to the ADC, vola! i'd even draw you a circuit diagram if i was near a computer!