Path: EDN Asia >> Design Ideas >> IC/Board/Systems Design >> How to drive 12 LEDs with one I/O line
IC/Board/Systems Design Share print

How to drive 12 LEDs with one I/O line

19 Aug 2015  | Charaf Laissoub

Share this page with your friends

Several articles expand the I/O of a pin-limited microcontroller (reference 1 through 4). The circuit in this design idea uses an alternative method (figure 1). It limits external additional parts to one IC, and it drives as many as 12 LEDs in dot-bar or bar-graph mode. You can use the same technique in a dot-bar design (figure 2). If you need a seven-segment LED display, you can use the circuit in figure 3, which shows how to rearrange the circuit according to a classic multiplexed, four-digit common-cathode display. The prototype display uses Kingbright's SC52-11EWA high-efficiency LEDs, which emit 2000 to 5600µcd at a forward current of 10 mA. The driver is a 12-stage NXP 74HCT4040 binary counter or a 74HC4040 version for a lower power supply.

Figure 1: A 12-LED dot-bar/bar-graph display uses a 12-stage binary counter.

Figure 2: Using one current-limiting resistor can reduce parts count.

Listing 1 contains an assembly-language routine. It generates a precise quantity, Q, of high-frequency pulses, which deliver the number, N, that the outputs of the 74HCT4040 require. The relations are Q=2N–1 in dot-bar mode and Q=2N–1 in bar-graph mode. Listing 2 is a full example of using this routine with Microchip's PIC10F202, a member of the PIC10F series, which is the company's most pin-limited microcontroller family.

Figure 3: The same technique works with seven-segment displays.

Although the PIC's internal unique clock frequency is 4MHz, you'll notice little flicker effect. You can reduce the flicker by using a midrange pin-limited PIC microcontroller, such as the PIC12F629, which has an internal clock frequency of 20MHz. Listing 3 uses a look-up table to convert the desired number into seven-segment code to replace the 12 LEDs with a four-digit display.

Anonymous, "Microcontroller provides low-cost analog-to-digital conversion, drives seven-segment displays," EDN, May 10, 2007, pg 80.

Raynus, Abel, "Squeeze extra outputs from a pin-limited microcontroller," EDN, Aug 4, 2005, pg 96.

Jayapal, R, PhD, "Microcontroller's single I/O-port line drives a bar-graph display," EDN, July 6, 2006, p 90.

Lekic, Nedjeljko, and Zoran Mijanovic, "Three microcontroller ports drive 12 LEDs," EDN, Dec 15, 2006, pg 67.

About the author
Charaf Laissoub is from Maisons Alfort, France.

This article is a Design Idea selected for re-publication by the editors. It was first published on February 4, 2010 in

Want to more of this to be delivered to you for FREE?

Subscribe to EDN Asia alerts and receive the latest design ideas and product news in your inbox.

Got to make sure you're not a robot. Please enter the code displayed on the right.

Time to activate your subscription - it's easy!

We have sent an activate request to your registerd e-email. Simply click on the link to activate your subscription.

We're doing this to protect your privacy and ensure you successfully receive your e-mail alerts.

Add New Comment
Visitor (To avoid code verification, simply login or register with us. It is fast and free!)
*Verify code:
Tech Impact

Regional Roundup
Control this smart glass with the blink of an eye
K-Glass 2 detects users' eye movements to point the cursor to recognise computer icons or objects in the Internet, and uses winks for commands. The researchers call this interface the "i-Mouse."

GlobalFoundries extends grants to Singapore students
ARM, Tencent Games team up to improve mobile gaming

News | Products | Design Features | Regional Roundup | Tech Impact