Exp-03

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

NAME: Prisha Singhania SAPID: 60002200135 BATCH: E2-4

Experiment No.:3 Date: 08-10-2022

Title: Interfacing of 7-segment display with 8051 microcontroller.

Objectives: At the end of this experiment, students will be able to find 7-segment code for decimal
number, concept of lookup table. Student will able to make hardware circuit for 7-segment interfacing
with microcontroller. Also student will able to write programing using instruction set.

Simulation Software: KEIL-µvision5 and Proteus 8 Professional.

Theory:
The 7-segment display, also written as “seven segment display”, consists of seven LEDs arranged in
a rectangular fashion as shown. Each of the seven LEDs is called a segment because when illuminated
the segment forms part of a numerical digit (both Decimal and Hex) to be displayed. An additional
8th LED is sometimes used within the same package thus allowing the indication of a decimal point,
(DP) when two or more 7-segment displays are connected together to display numbers greater than
ten. Each one of the seven LEDs in the display is given a positional segment with one of its connection
pins being brought straight out of the rectangular plastic package. These individually LED pins are
labelled from a through to g representing each individual LED. The other LED pins are connected
together and wired to form a common pin. So by forward biasing the appropriate pins of the LED
segments in a particular order, some segments will be light and others will be dark allowing the
desired character pattern of the number to be generated on the display. This then allows us to display
each of the ten decimal digits 0 through to 9 on the same 7-segment display.The displays common
pin is generally used to identify which type of 7-segment display it is. As each LED has two
connecting pins, one called the “Anode” and the other called the “Cathode”, there are therefore two
types of LED 7-segment display called: Common Cathode (CC) and Common Anode (CA). The
difference between the two displays, as their name suggests, is that the common cathode has all the
cathodes of the 7-segments connected directly together and the common anode has all the anodes of
the 7-segments connected together and is illuminated as follows.The Common Cathode (CC) – In the
common cathode display, all the cathode connections

Subject:Microprocessor & Microcontroller TE/SEM-V Page No.


of the LED segments are joined together to logic “0” or ground. The individual segments are
illuminated by application of a “HIGH”, or logic “1” signal via a current limiting resistor to
forward bias the individual Anode terminals (a-g).

Algorithm:

a) Initialize memory PTR with starting offset of lookup table of seven segment code.
b) Initialize counter to 10.
c) Initialize port as a output port.
d) Get the seven segment code from the lookup table pointed by MEM_PTR.
e) Send to port A to display digit.
f) Create Delay.
g) Increment MEM_PTR by 1.
h) Decrement counter by 1.
i) Is counter = 0? If no goto step d else goto step j
j) Go to step b.
k) STOP.

Display Selection using decoder select lines


Display No. P3.7 P3.6 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0 Code
Display-1 0 0 0 0 0 0 0 0 0x00
Display-2 0 0 0 0 0 0 0 1 0x01
Display-3 0 0 0 0 0 0 1 0 0x02
Display-4 0 0 0 0 0 0 1 1 0x03

Subject:Microprocessor & Microcontroller TE/SEM-V Page No.


Common Anode Diagram
Look Up table for Common Anode 7-segment display
Decimal Seven segment display pins. Code
No. h g f e d c b a
0 1 1 0 0 0 0 0 0 C0
1 1 1 1 1 1 0 0 1 F9
2 1 0 1 0 0 1 0 0 A4
3 1 0 1 1 0 0 0 0 B0
4 1 0 0 1 1 0 1 1 9B
5 1 0 0 1 0 0 1 0 92
6 1 0 0 0 0 0 1 0 82
7 1 1 1 1 1 0 0 0 F8
8 1 0 0 0 0 0 0 0 80
9 1 0 0 1 1 0 0 0 98

PinOut:

Subject:Microprocessor & Microcontroller TE/SEM-V Page No.


Subject:Microprocessor & Microcontroller TE/SEM-V Page No.
Code:
#include<reg51.h>
void delay(int k)
{ int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<1250;j++0);
}
}
void main()
{
unsigned char i;

Subject:Microprocessor & Microcontroller TE/SEM-V Page No.


unsigned
seg[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
unsigned mode[4]={0x00,0x01,0x02,0x03};
while(1)
{
unsigned char j;
j=0;
for(i=0;i<10;i++)
{
j=j%4;
P3=mode[j];
P1=seg[i];
delay(20);
j++;
}
}
}
Output: (If the video is not opening then check the videos attached with the assignment)

7-segment
display.mp4

Conclusion:

Subject:Microprocessor & Microcontroller TE/SEM-V Page No.

You might also like