## Introduction

In this tutorial we will learn about the interfacing of seven segment display with 8051 controller. Before interfacing the seven segment we must be know about the types of seven segment and their controlling logic.As we know 7 segment are two types common anode and common cathode. In common cathode LED is glow by positive logic (1) and in common anode type it operate on low logic (0).

Required circuit component:

• Microcontroller – AT89C52
• 7 segment LED Display (Common Cathode)
• Resistors -(330R) – {R1 to R8}
• Crystal oscillators – (11.0592MHz)
• Capacitors-(2)-33pf -{C1 to C2}

## Algorithm

We want to display digit (0-9) on “7 segment display” continuously……

• First we connect the pins of “7 segment display” to any port of microcontroller “AT89S52”. And common cathode pin to the “GROUND”.
• Here we used “PORT 2”.
• Now how to work “7 segment display” .
• In “7 segment display” 7 LED’S are in-built it.
• If we want to glow any LED then it is required that it should be at its minimum voltage i.e. ‘2V’.
• So if we give logic ‘1’ i.e. ‘5V’ then it may be damage because we want only ‘2V’ so we connect LED’S to resistor.
• Now how to display digits:- we should glow “LED a, LED b, LED c, LED d, LED e, LED f.
• so we gives these LED’s logic ‘1’.
• For display digit ‘1′
•  we should glow “ LED b, LED c”, to display 1 we need to send hexadecimal value on the port of the microcontroller (i.e. 06).

Now to display any digit on the 7 segment display we have to give hexadecimal code at the port of the microcontroller. Therefore here is below table to show each number hexadecimal value for the common cathode 7 segment display.

### Table: Common Cathode

 DIGIT g(P2.6) f(P2.5) e(P2.4) d(P2.3) c(P2.2) b(P2.1) a(P2.0) HEX Value 0 0 1 1 1 1 1 1 0x3f 1 0 0 0 0 1 1 0 0x06 2 1 0 1 1 0 1 1 0x5b 3 0 0 0 1 1 1 1 0x0f 4 1 1 0 0 1 1 0 0x66 5 1 1 0 1 1 0 1 0x6d 6 1 1 1 1 1 0 0 0x7c 7 0 0 0 0 1 1 1 0x07 8 1 1 1 1 1 1 1 0x7f 9 1 1 0 1 1 1 1 0x6f

## Applications

• Used in traffic light for display number
• Widely used in digital clock
• Used in electric meter to display numerical information