[664] Two LEDs on 1 AVR line

Date: May 25th, 2010 | Comments : [3] | Categories: DIY.

Bicolor LED

This is a simple method to control two LEDs with one output pin on a microprocessor. I breadboarded this recently to test the concept for a project that I have in the works.

When the output pin 6 of the ATtiny11 micro is in the ON (or high) state, the bottom (green) LED will be active and lit up. The red LED will be off at this point.

If the output pin is toggled to the OFF (low) state, the green LED goes off and the red LED comes on. Toggling the output pin alternates between the two LEDs.

 

3 Responses to “Two LEDs on 1 AVR line”

[1077] admin Says: 5:23 pm, May 27th, 2010

This is better than charlieplexing for small numbers of LEDs… each AVR or PIC output pin with this method can drive 2 LEDs. If you are using 3 output pins, then 6 LEDs can be controlled, which is the same as with charlieplexing. However, 2 output pins in charlieplexing can only control 2 LEDs, but 4 can be used with this method, and nothing can be done with 1 charlieplexed pin and 2 are controlled here.

For more than 6 indicators, charlieplexing is the way to go but for 6 or less, this is a better idea, especially since it is so easy to write code for it. Just toggle the right pin to turn on a selected LED – no matrix to worry about and no tri-state!


[1281] Skot Wiedmann Says: 1:01 pm, August 5th, 2010

Save one resistor by connecting it between the pin and the LED instead. Or raise the resistor values enough that a tristate pin can let them both float off. Then you can use a fairly fast square wave to turn them both on. 4 states from one output pin!


[1283] admin Says: 7:17 am, August 7th, 2010

Skot, I tried the single resistor version first and it did not work as well as having separate resistors… if fact, if I’m not mistaken, it would not work at all.

I think if you tri-state the micro pin, both LEDs should be lit in my version. I’ve been planning on breadboarding this to check it out.

-Jack




 

AMZ Home Page

Guitar FX PCBs

PRIVACY POLICY