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

EXPERIMENT NO : 03

Aim : To understand the basics of seven segment display and to display


numerical values and alphabets on it using 8051 .
THEORY :
A seven-segment display is a common output device consisting of seven
individual LED segments arranged in the shape of the numeral 8. Each segment
is labeled 'a' through 'g' and represents a portion of a numeral or letter. The
display can be either common anode or common cathode. In a common anode
display, all anodes are connected, while in a common cathode display, all
cathodes are connected. The 8051 microcontroller can interface with a
sevensegment display by connecting the common pins to the power source and
the individual segment pins to microcontroller output pins.

To display numerical values, each digit is represented by turning on specific


segments. For instance, to display the numeral "0," segments 'a' through 'f' are
activated. Alphabets can also be displayed on a seven-segment display with
limitations due to the available segments. For example, 'A,' 'b,' 'C,' 'd,' 'E,' 'F,'
and 'h' are feasible, while others require creativity due to the display's
sevensegment constraint.

Programming the 8051 involves writing code, usually in assembly or C, to


control the segments based on the desired character. The microcontroller
manipulates the port pins connected to the seven-segment display to turn on or
off specific segments. To display multiple characters, multiplexing can be
employed. This technique rapidly switches between digits, giving the illusion of
simultaneous display.

Seven-segment displays find applications in digital clocks, temperature


indicators, and numeric displays, providing a straightforward yet effective
means of conveying information in a visual format. Understanding their
interfacing with the 8051 microcontroller allows for the creation of diverse
applications in embedded systems.
Program: 1 (For Displaying A on DIS 1) const
char TH1_INIT = 0xF0; // Ini al/Reset value, controls

Timer1 period const char TL1_INIT = 0x00; void main

{
P0=0;
P1=0;
TF1_bit = 0; // Ensure that Timer1 interrupt flag is cleared
ET1_bit = 1; // Enable Timer1 interrupt
EA_bit = 1; // Set global interrupt enable
GATE1_bit = 0; // Clear this flag to enable Timer1 whenever TR1 bit is set.
C_T1_bit = 0; // Set Timer opera on: Timer1 counts the divided-down systam
clock.
M11_bit = 0; // M11_M01 = 01 => Mode 1(16-bit Timer/Counter)
M01_bit = 1;
TR1_bit = 0; // Turn off Timer1
TH1 = TH1_INIT; // Set Timer1 high byte
TL1 = TL1_INIT; // Set Timer1 low byte
TR1_bit = 1; // Run Timer1
P0=0x88;
P1=0x01;
return ;
}

Fig 3.3 Display of Alpha numeric ‘A’ in Display Port 1 of MicroC


Program: 2 (For Displaying E on DIS 3) const char

TH1_INIT = 0xF0; // Ini al/Reset value, controls Timer1

period const char TL1_INIT = 0x00; void main

{
P0=0;
P1=0;
TF1_bit = 0; // Ensure that Timer1 interrupt flag is cleared
ET1_bit = 1; // Enable Timer1 interrupt
EA_bit = 1; // Set global interrupt enable
GATE1_bit = 0; // Clear this flag to enable Timer1 whenever TR1 bit is set.
C_T1_bit = 0; // Set Timer opera on: Timer1 counts the divided-down systam
clock.
M11_bit = 0; // M11_M01 = 01 => Mode 1(16-bit Timer/Counter)
M01_bit = 1;
TR1_bit = 0; // Turn off Timer1
TH1 = TH1_INIT; // Set Timer1 high byte
TL1 = TL1_INIT; // Set Timer1 low byte
TR1_bit = 1; // Run Timer1
P0=0x86;
P1=0x08;

return ;
}

Fig 3.3 Display of Alpha numeric ‘E’ in Display Port 1 of MicroC


Result : BCD to Seven Segment Display has been performed and verified in
microC PRO
Fig 3.1 Truth Table for a 7-segment display

Fig 3.2:- 7-Segment Display Elements for all Numbers.

It can be seen that to display any single digit number from 0 to 9 in binary or
letters from A to F in hexadecimal, we would require seven separate segment
connections plus one additional connection for the LED’s “common”
connection.

You might also like