Electronic – Control a bicolor LED with just one pin

led

Is it possible to control a bicolor LED with just one pin of a microcontroller?

Instinct says NO, because you can have one end grounded and the other going to the micro's pin, allowing you to turn it on or off but not change its color.

But maybe someone has a better idea?

Best Answer

You can do this with a bi-color LED that has the two LEDs back-to-back if you connect one LED terminal to an intermediate voltage eg 2.5V on a 5V design and connect the other side to the MCU via a suitable resistor (I used 560R).

Then a low output gives one colour, high gives the other and tri-state leaves the LED off. Pulse width modulation will allow you to control brightness (switching output between active and tri-state) or mix the colours (switching output low to high).

You can adjust the intermediate voltage to compensate for different LED forward voltages too.

I used an LM2904 op-amp to provide the intermediate voltage - it works with supply voltage down to 5V. There are plenty of other devices that can operate at lower voltages and still sink and source enough current to drive the LEDs.