In trying to save precious I/O lines, I wanted to use one line for three states:
Red (logic 1), green (logic 0), and off (tri-state).
The way this SMD bi-color LED is connected is:
The idea being that together, the forward voltages of these LEDs is more than 3.3V, so they can’t both light up. Both are rated at 2.0 V typical (2.4 V max) forward voltage.
And in fact it almost works as expected. The only problem is that when the I/O pin is left floating, the red LED still lights up dimly – it’s hard to see in the photo, but it really does.
These LEDs are rated at 80 mA peak and 30 mA continuous, btw – so I figured I wouldn’t need a resistor, at least for the test. For a more permanent setup, a 100 Ω resistor between this circuit and the I/O pin would probably be better.
I wonder if there is a simple way to turn the red LED completely off – a 1N4148 diode between 3.3V and the red LED perhaps? That might also dim it a bit, since it’s brighter than the green one.
Geek news: this is post # 2^8 :)
Update – the extra diode helps. Here’s a better test, showing red, orange, green and off:
The “orange” isn’t truly convincing with the clear LED I’m using, but its reflection on a piece of white paper looks ok.
Four states on a single I/O pin!