INTRODUCTION:
This post is about to interface a seven segment LED display to an 8051 microcontroller. Seven segment LED display is very popular and it’s just 7 LEDs that have been combined into one case to make a convenient device for displaying numbers and some letters. Knowledge about how to interface a seven segment display to a microcontroller is very helpful in designing embedded systems. A seven segment display consists of seven LEDs arranged in the form of a “squarish eight” slightly inclined to the right and a single LED as the dot character. Different characters can be displayed by selectively glowing the required LED segments.
Seven segment displays are of two types,
Common Cathode: In this method, all segment share common cathode.
Common Anode: In this method, all segment share common anode.
Here common anode seven segment display is used because the output current of the microcontroller is not sufficient enough to drive the LED’s. In order to turn ON a segment the corresponding pin must be set to 0 and to turn it OFF it is set to 1.
A resistor is required to limit the current. Rather than using a resistor from each LED to ground, you can just use one resistor from Vcc to pin 3 (‘com’) to limit the current.
DIGIT DRIVE PATTERN:
Digit drive pattern of a seven segment LED display is simply the different logic combinations of its seven segment terminals ‘a’ to ‘h’ in order to display different digits and characters. The common patterns (0 to 9) of a seven segment display are shown in the table below.
CIRCUIT DIAGRAM:
INTERFACING CODE:
// Programming for interfacing of Seven Segment Display to 8051
#include<reg51.h>
delay_ms(int time) // Time delay function
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void main()
{
char num[]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};
// Hex values corresponding to digits 0 to 9
int s;
while(1)
{
for(s=0;s<10;s++)
{
P2=num[s];
delay_ms(200);
}
}
}
search4electronics2013.blogspot.com please visit
ReplyDeletegood tutorial. which schematic software was used for drawing circuit diagram.
ReplyDelete