Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?

[Ideas For Design]

Circuit Controls Two LEDs With One Microcontroller Port Pin



Spehro Pefhany  |   ED Online ID #1683  |   April 01, 2002

Article Rating:

Microcontroller port pins can typically be driven either high or low, or else be put into an "input" or high-impedance state. This circuit uses the three states to drive two separate LEDs with one port pin. This can be very useful when there are no port pins to spare—something that usually happens.

The simple way to drive two LEDs is via two port pins (Fig. 1a). The improved version requires only one additional resistor (Fig. 1b). It can be designed for most reasonable LED voltages and supply voltages, as well as to yield the desired "on" currents in each LED, which may be different if desired. The design parameters are:

V1 = off voltage for D1 (worst case maximum voltage for no visible light from D1)

V2 = off voltage for D2 (worst case maximum voltage for no visible light from D2)

V3 = on voltage for D1 (forward voltage of D1 at design current plus port voltage drop)

V4 = on voltage for D2 (forward voltage of D2 at design current plus port voltage drop)

Ion1 = desired on current for D1

Ion2 = desired on current for D2

Vcc = supply voltage

The design equations are:

Ion1 = [(Vcc − V3)/R1] − [V3/(R2 + R3)]

Ion2 = [(Vcc− V4)/R2] − [V4/(R1 + R3)]

(V1 + V2)/R3 = (Vcc − V1 − V2)/(R1 + R2)

To minimize current consumption, R3 is made as large as possible, without the LEDs turning on with the port pin in the high-impedance state.

These equations can be solved by using an Excel spreadsheet (Fig. 2). This minimizes the sum of the squares of the errors of each LED's on current, as compared to the design values. Inserting typical values as follows, assume one yellow and one red LED for D1 and D2, respectively:

V1 = 1.2 V

V2 = 1.1 V

V3 = 2.2 V (inclusive of port-pin voltage drop when sourcing current)

V4 = 1.9 V (inclusive of port-pin voltage drop when sinking current)

Ion1 = 0.008 A

Ion2 = 0.008 A

Vcc = 5.0 V

The solver tool comes up with values that can be rounded to the closest 5% standard resistance values as follows:

R1 = 300 Ω

R2 = 330 Ω

R3 = 1.2 kΩ

Then, the practical resistor values can be plugged into the same cells that the solver modified, to read the resulting currents and quiescent current, Iq. In this case, the circuit draws a quiescent current of 2.7 mA when both LEDs are off. When it's on, the circuit supplies almost exactly 8 mA to each LED. If it's desired to have both LEDs appear on, the port pin can be rapidly cycled between 0 V and Vcc. If the rate is somewhere around 100 Hz or higher, both LEDs will appear steadily illuminated.

This circuit works best with microcontrollers that have Schmitt-trigger or analog inputs. Other types may draw unnecessary supply current if the input is biased close to the center of the supply voltage.




Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


  • C Tools Accelerate HDV Development On Xilinx FPGAs
  • A New Design Inflection Point
  • Forecasting Industry Growth For 2009 And Beyond
  • EDA Retools To Exploit Multicore Architectures
  • Design And Verification Move Up In Abstraction
  • EDA Retools To Exploit Multicore Architectures
  • A New Design Inflection Point
  • Design And Verification Move Up In Abstraction
    1) Transportation Guidelines For Lithium Batteries Get Updated
    (1224 views today)
    2) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (282 views today)
    3) WHITE PAPER: Liquid-Level Monitoring Using a Pressure Sensor
    (204 views today)
    4) 1-A Switching Regulators Operate With 96% Efficiency To Replace Linear Regulators
    (137 views today)
    5) The Field Of Energy Harvesting Begins To Ripen
    (107 views today)
    ALL TOP 20







    Reader Comments

    my teacher asked me to do a board that 1)must have the power suply on ,the RS232 on the board to program pic to comunicate with my pc and of course the pic or basic stamp microcontroller circuit.all this to make two leds connected to the pic or basic stamp light in this way:the circuit must have a switch when the switch is off the first led blink when the switch is on the other led must blink.All this to take a 5 with excellent 10. somebody who knows please tell me is it fair?he wants the programmer and the circuit with leds.all this without telling us anything.Please if somebody can help me i would be so grateful!!!! thank you your job is excelllent.

    Anonymous -May 23, 2007

    my teacher asked me to do a board that 1)must have the power suply on ,the RS232 on the board to program pic to comunicate with my pc and of course the pic or basic stamp microcontroller circuit.all this to make two leds connected to the pic or basic stamp light in this way:the circuit must have a switch when the switch is off the first led blink when the switch is off the other led must blink.All this to take a 5 with excellent 10. somebody who knows please tell me is it fair?he wants the programmer and the circuit with leds.all this without telling us anything.Please if somebody can help me i would be so grateful!!!! thank you your job is excelllent.

    Anonymous -May 23, 2007

    It is good solution, but most of the microcontroller port pins are not designed to drive leds directly. u need to use a trasistor or any other driver IC.

    Anonymous -August 02, 2006   (Article Rating: )
    Read more comments...

    POST YOUR COMMENTS HERE

    Name:

    Email:
    Rate this article:

     less useful more useful 
    1
    2
    3
    4
    5
    Your Comments:

    Enter the text from the image below




    Please refresh the page if you have trouble reading this text.
     
     

    PartFinder

    Find real-time pricing, stock status, same-day/next-day shipping options and more. Brought to you by Digi-Key. Go to PartFinder.    
    GlobalSpec

    PART SEARCH :
    Powered by: GlobalSpec - The Engineering Search Engine
    Sponsored Links

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources