Circuit Controls Two LEDs With One Microcontroller Port Pin
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)
The design equations are:
Ion1 = [(Vcc − V3)/R1] − [V3/(R2 + R3)]
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
The solver tool comes up with values that can be rounded to the closest 5% standard resistance values as follows:
R1 = 300 Ω
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.
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw
News on theme: