Design Idea

Single-port pin drives dual LED

Single-line LED driving can be versatile.

By Tom Gay, Dornstadt, Germany; Edited by Brad Thompson and Fran Granville -- EDN, 10/13/2005

Most current microcontrollers offer I/O ports that can change their functions during program execution. As outputs, the circuits can sink and source reasonably large amounts of current. This Design Idea shows three alternative methods for driving a two-pin, two-color LED from a single I/O pin. Figure 1 illustrates one possible approach that uses external inverter IC1 to drive D1, a red/green bidirectional LED. A logic-high output on the port pin forces current through the green (upper) LED and pulls the inverter's input high, which drives the inverter's output low and sinks current from the green LED. A logic-low output on the port pin raises the inverter's output high, delivering current to the red (lower) LED; the microcontroller's output sinks current from the red LED.

To turn off both LEDs, you reconfigure the microcontroller's port pin from output to input or switch the pin to tristate mode, either of which prevents the microcontroller's port pin from sourcing or sinking current. This circuit's primary disadvantage is that it yields no control over each LED's brightness; instead, resistor R5 determines forward current for both LEDs.

Figure 2 presents an approach that also involves a major disadvantage. Zener diodes D3 and D4 and resistors R3 and R4 form a low-impedance voltage divider that applies VCC/2V to one end of LED D5. The value of VCC drives the selection of the zener diodes' voltage, VZ, with lower voltage zener diodes allowing more LED current and higher voltage ones limiting maximum LED current. Given that the microcontroller's outputs can deliver rail-to-rail voltages, the difference between VCC and VZ limits maximum forward current for both LEDs. For example, if VCC is 5V and VZ is 3V, the forward voltage across either LED is less than 2V. Once a designer selects the zener-diode voltage, only small variations in VCC can occur; otherwise, the LEDs' brightness would fluctuate.

Using discrete components, another circuit offers an inexpensive approach that avoids the other circuits' disadvantages (Figure 3). When the microcontroller's output port goes high, current flows through the green (upper) LED, R2, D2, and FET Q2, which the port's high level turns on. When the microcontroller's output port goes low, transistor Q1 turns on and delivers current to the port pin through R2 and the red (lower) LED. The circuit operates symmetrically because silicon diode D2's forward-voltage drop is present regardless of whether the microcontroller's port pin goes high or low. VCC may vary during operation but must remain higher than 3V.

You can individually adjust the LEDs' currents to equalize brightness or compensate for a difference between the microcontroller's power-supply voltage and the LED-driver circuit's VCC. Replace R2 with two resistors connected in series between Q1's emitter and D2's anode. Connect the midpoint of the two resistors to the LEDs.

With the microcontroller's port pin configured as an "input with pullup," the port delivers a small current to the green LED. However, pullup-resistor values of 22 kΩ or higher do not cause misleading light output from LEDs in the off-state. When the input signal from the port pin floats—that is, with VCC at 5V and the port configured as an input with no pullup resistor—the circuit draws no additional current, and the quiescent current, which R1 determines, averages less than 100 µA.

 



Click here for more Design Ideas!



Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Feedback Loop


Post a CommentPost a Comment

There are no comments posted for this article.

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites