Binary To Decimal 7-Segment LED Display Project

Binary To Decimal 7-Segment LED Display Project

In the previous part we built a 3-bit binary adder to add two numbers, however it outputs the result of the calculation in binary. It might be more convenient if it could output the result in decimal instead. This section adds an LED display that can show the result of the calculation in decimal.

A seven segment LED display (usually) consists of 8 LEDs in a single package and can display the numbers 0 - 9 by turning on the LEDs in patterns. Seven LEDs form the digit to be displayed an an 8th LED can be used for a decimal point. We’ll not be needing the decimal point in this project. The display contains only regular LEDs and does not contain any electronics for forming the patterns needed. It just has one pin on the back connected to each of the LEDs.

Converting binary into the patterns of LEDs to form each number needs quite a lot of logic gates, but you can get chips to do the job which makes the process a whole lot easier. The chip I have chosen is the HEF4543BP. This chip is a binary coded decimal to 7-segment decoder. It accepts a 4-bit binary pattern which is exactly what our 3-bit calculator outputs.

It may be noted that the addition result from two 3-bit numbers can be more than 9, which is the highest number that this single display can show. When this happens this chip will cause the display to go blank. We’ll leave numbers larger than 9 as a problem for another day.

The pinout for the chip looks like this:

The pinout of the HEF4543BP chip.

The 4-bit binary number to be displayed is input on the pins labelled D0 - D3 (note they are not in order). The pins that connect to the 7 segments of the LEDs are labelled Qa - Qf on the right of the chip (note again, not quite in order). Q is commonly used in electronics to mean output. A - F refers to the traditional labelling of the seven LED segments which looks like this:

The labelling of segments on a 7 segment display.

We have 5v needed on pin 16 and ground on pin 8. The remaining pins are PH, BL and LE (with a bar over it). The PH pin is a configuration setting. There are two types of LED display, common anode or common cathode. The former means the display has all of the positives for the LEDs connected together and presented as one pin. The latter means it has all of the negatives connected together and attached to same pin on the display. In this case I have a common anode display. For this type PH must be set high, that is connected to 5V. For the common cathode type it must be connected to ground.

The BL pin is used to turn off the display. We don’t need to use that in this project and it is connected to ground to permanently enable the display.

The LE pin provides a latch facility. This fixes the number on the display, even if the D0 - D3 inputs are changed. It may be the case that the D0 - D3 inputs are rapidly switching around due to the operation of the calculator and this would scramble the number on the display or cause flicker while this was happening until such time as the number at the inputs stabilised. In this case we don’t have that problem and set this pin high (to 5V). This causes changes to the D0 - D3 pins to be instantly reflected on the display.

The full circuit on a breadboard layout is shown below. The only additional components are 120Ω resistors to limit the current flow to the LEDs in the display. The display is not on the board because the pitch of the pins on this particular part does not match the breadboard, so it has been connected up with dupont connectors and left hanging off the board instead.

Schematic diagram showing the connections from the HEF4543BP chip to the 7 segment LED display on a breadboard.

This circuit is connected up to the 3-bit adder outputs. The four LEDs from the previous project (and associated resistors) have been removed from the board and the wires connecting to them have been connected directly to the relevant bits on the HEF4543BP chip input instead. The 5V and Ground rails on the display breadboard have also been connected across to the adder project board.

Two breadboards side by side. The left hand board has the 3-bit adder circuit. The right hand board has the 7 segment display decoder.

The display initially shows zero. Then, when buttons are pressed to input the calculation, the correct result should show on the display:

Close-up of the 7 segment LED display showing the number 5.