PIC microprocessor drives 20-LED dot- or bar-graph display

Noureddine Benabadji, University of Sciences and Technology, Oran, Algeria; Edited by Brad Thompson and Fran Granville -- 9/1/2006

The circuit in Figure 1 uses only five I/O lines to drive a dot- or bar-graph display of 20 LEDs. Although this version of the design uses a small and inexpensive one-time-programmable microprocessor, such as a Microchip PIC12C508A, you can use other microprocessors with N I/O lines to drive as many as N×(N–1) LEDs. For software development or modification, you can use a PIC12C508A-JW reprogrammable-EPROM version of the PIC12C508A, or you can substitute a less expensive PIC16F84A with flash memory.

To avoid application of excessive reverse voltage to the LEDs, the circuit's power supply, VDD, must not exceed 3V dc. You can drive other types of loads and provide electrically isolated interfaces by replacing the LEDs with appropriately rated optocouplers. For demonstration purposes, IC1's input line, GP3, connects to a pushbutton display-mode-selector switch and a pulldown resistor that simulates a digital-input-signal source with a voltage amplitude of 3V p-p.

Listing 1 performs a variety of functions. To conserve battery power, the basic software drives one LED at a time in dot or bar mode with a minimum amount of current. Approximately 2 mA flashes a high-brightness LED. The software includes a delay routine that solves the problem of contact bounce. Tests show that a miniature pushbutton switch requires a delay of at least 1 msec for successful debouncing.

Consuming fewer than 256 words, the software avoids a C12C508A programming restriction that requires placement of subroutines only in page 0. Other features of the software include a two-level stack, the use of files common to both the PIC12C508A and the PIC16F84A in the 0CHto 1FH range, use of the RETLW 00H instruction instead of Return, and avoidance of the ADDLW and SUBLW instructions. The software defaults to the dot-display mode. Pressing and holding S1 before and during power application selects the bar-display mode. Note that the configuration settings for the MPASM assembler vary according to which microprocessor you select for programming.

ADVERTISEMENT

© 2009, Reed Business Information, a division of Reed Elsevier Inc. All Rights Reserved.