Need a simple display for an upcoming design? Check out this easy-to-replicate solution. Devlin presents a simple microcontroller-based circuit to animate a four-digit, seven-segment LED.
Inexpensive seven-segment, light-emitting diode (LED) displays were designed to represent the numbers zero through nine, but they occasionally are used to show the additional hexadecimal characters A through F. While it takes 14 segments to display the entire alphabet, you can easily display short messages on a seven-segment display. In this article, I’ll explain how I designed a simple circuit that uses an inexpensive Microchip Technology PIC16F630 microcontroller and a few other parts to animate text on a four-digit, seven-segment LED display (see Photo 1 and Photo 2).
Graphic displays have become ubiquitous in electronic devices, since their cost has continued to decline, but seven-segment displays are still used in many applications. While it’s now common to see seven-segment displays implemented using liquid crystal technology, LEDs are more appealing in applications such as digital clocks or when a readable display is needed in a dark room.
The original purpose of seven-segment displays was to indicate the decimal digits 0–9, and they do this quite well. Early computer development boards extended the seven-segment character set to the hexadecimal realm by adding the letters A–F, albeit in a functional, rather than aesthetic, fashion (see Figure 1). The uppercase characters A, C, E, and F, are adequately rendered, but not B and D. The “Ho” from Santa’s favorite exclamation, “Ho, Ho, Ho,” with both uppercase and lowercase characters, can be rendered in a seven-segment display. However, for maximal visual effect, it can be rendered in all capital letters as “HO” (see Figure 2). Red and green are traditional holiday colors, and seven-segment displays are readily available in both colors, but the human eye is more sensitive to green.
A static “HO-HO-HO,” including the hyphen character, is easily rendered using seven-segment displays, but an animated display is better. As you can see in Figure 3, it’s possible to use a common four-digit display to render a moving “HO-HO-HO.” The “HO” characters move across the display either sequentially, as shown in Figure 3, or randomly from place to place. In my implementation, I have four of these circuit ornaments intertwined with artificial holly to create a lively garland that I hang from a fireplace mantle. A string of as many of these as desired can be draped on a holiday tree as a set of animated ornaments.
CIRCUIT & SOFTWARE
Figure 4 shows the circuitry. The seven-segment display is a typical four-digit 0.56² character height green LED display. The 2N3906 PNP transistors multiplex the display digits through their common anodes, and the digit segments are multiplexed through current-limiting 100-Ω resistors by the 2N3904 NPN transistors. It isn’t necessary to address each segment individually to shift between an “H” character and an “O” character. Selecting the A and D segments, the B, C, E, and F segments, and the G segments in three groups, are all that’s required.
Jumpers J1 and J2 select the operating mode, which includes sequential to the right, sequential to the left, and random, as shown in Table 1. To prevent display flicker while addressing the mode, it’s read just once when power is applied. To change mode, you need to change the jumper, remove power, and then apply power again. The circuit draws just 75 mA from its 5-VDC supply, so my string of four units is powered by a 5-VDC regulated wall wart power supply rated at 500 mA.
Photo 2a shows the component side of the circuit board. To make the unit as compact as possible, the display is mounted on the foil side of the board, as shown in Photo 2b. I used single-row socket strips to have the display pluggable, but it can be soldered directly to the board. A dual inline integrated circuit socket can be cut apart to make suitable connectors. Figure 5 shows the component placement on the circuit board.
I wrote the source code for this project in PIC Basic Professional. Its use of a timer interrupt provides an easy method for multiplexing the display.
The circuitry uses the PIC16F630, but the PIC16F676 is a pin-compatible replacement that contains A/D converters. If these A/D converters are disabled in the software, the PIC16F676 will work too. Using a UL-listed wall wart power supply is important for safety reasons. A bench “burn-in” is also recommended to uncover any problems with your construction before placing the ornaments on a potentially flammable tree.
Microchip Technology, “PIC16F630/676 Datasheet: 14-Pin, Flash-Based 8-Bit CMOS Microcontrollers,” DS40039F, 2010.
PUBLISHED IN CIRCUIT CELLAR MAGAZINE • NOVEMBER 2016 #316 – Get a PDF of the issue