Interfacing with Seven Segment LED Display
Interfacing with Seven Segment LED Display
7 segment LED display is very popular and it can display digits from 0 to 9 and quite a few characters
like A, b, C, ., H, E, e, F, n, o,t,u,y, etc. Knowledge about how to interface a seven segment display to
a micro controller is very essential in designing embedded systems. 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. Different characters can be displayed by selectively glowing the required LED
segments. Seven segment displays are of two types, common cathode and common anode. In
common cathode type , the cathode of all LEDs are tied together to a single terminal which is usually
labeled as ‘com‘ and the anode of all LEDs are left alone as individual pins labeled as a, b, c, d, e, f, g
& h (or dot) . In common anode type, the anode of all LEDs are tied together as a single terminal and
cathodes are left alone as individual pins. The pin out scheme and picture of a typical 7 segment LED
display is shown in the image below.
Digit drive pattern of a seven segment LED display is simply the different logic combinations of its
terminals ‘a’ to ‘h‘ in order to display different digits and characters. The common digit drive
patterns (0 to 9) of a seven segment display are shown in the table below.
Digit a b c d e f g
0 1 1 1 1 1 1 0
1 0 1 1 0 0 0 0
2 1 1 0 1 1 0 1
3 1 1 1 1 0 0 1
4 0 1 1 0 0 1 1
5 1 0 1 1 0 1 1
6 1 0 1 1 1 1 1
7 1 1 1 0 0 0 0
8 1 1 1 1 1 1 1
9 1 1 1 1 0 1 1
C – Program :
#include<reg51.h>
void msdelay(unsigned int time) // Function for creating delay in milliseconds.
{
unsigned i,j ;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void main()
{
unsigned char no_code[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //Array for hex
values (0-9) for common anode 7 segment
int k;
while(1)
{
for(k=0;k<10;k++)
{
P2=no_code[k];
msdelay(100);
}
}
}