Interfacing Seven Segment Display To 89c52

John Fashanu
3 min readAug 27, 2021

--

Brief Overview Of Seven Segment Display

A seven segment display consists of seven LEDs arranged in the form of a squarish ‘8’ slightly inclined to the right and a single LED as the dot character. It’s the simplest unit to display numbers and characters. Different characters can be displayed by selectively glowing the required LED segments. It can display the numbers, 0 to 9, A, b, C, E, e, F, H, n, o, t, u, y, and so on.

7 Segment Display

They have many applications and are very popular. There are two types of seven segment display namely;

· Common Cathode

· Common Anode

In common cathode type , the cathode of all LEDs are tied together to a single terminal and labelled as com. and the anode of all LEDs are left alone as individual pins labelled as a, b, c, d, e, f, g and h(dot).

The common anode type is simply the opposite of the cathode type. Here, the anode of all LEDs is tied together to a single terminal and the cathodes are left alone as individual pins.

Digit Drive Pattern

Displaying different digits on a 7 segment display is simply glowing different logic combinations of its terminals. The table below shows the common digit drive pattern of a 7 segment common cathode display.

Interfacing Seven Segment Display To 89c52

As shown above the circuit diagram for interfacing 7 segment display with 8051 microcontroller, we have connected a, b, c, d, e, f, g, h to pins 2.0 to 2.7 means we are connecting 7 segment to port 2 of microcontroller. Now suppose we want to display 0, then we need to glow all the LEDs except LED which belongs to line “g, so pins 2.0 to 2.6 should be at 0 (should be 0 to TURN ON the LED as per negative logic) and pin 2.7 and 2.8 should be at 1 (should be 1 to TURN OFF the LED as per negative logic). So the LEDs connected to pins 2.0 to 2.6 (a, b, c, d, e, f) will be ON and LEDs connected to 2.7 and 2.8 (g and h) will be OFF, that will create a “0” in 7 segment. So we need bit pattern 11000000 (Pin 8 is the highest bit so starting from P2.7 to P2.0), and the HEX code for binary 11000000 is “C0”. Similarly we can calculate for all the digits. Here we should note that we are keeping “dot/h” always OFF, so we need to give LOGIC “1” to it every time.

--

--