Homework 2
Anshul Gour
September 2, 2019
Q-2. Sketch the pin diagram of common cathode and common anode seven segment
LED with the brief explanation of working principle.
Figure 1: Pin diagram of common anode seven segment led
Figure 2: Pin diagram of common cathode seven segment led
1
Working Principle:- When the power is given to all the segments, then the number 8 will be
displayed. If you disconnect the power for segment G (that means 7) then that will result number 0.
The circuit of the seven segment display is designed in such a way that the voltage at different pins can
be applied at the same time. In the same way, you can form the combinations to display numerals from
0 to 9.
Practically, seven segment displays are available with two structures, both the type of displays consists
of 10 pins.
Common Cathode 7-segment Display
In this type of display, all the cathode connections of the LED segments are connected together to logic
0 or ground. The separate segments are lightened by applying the logic 1 or HIGH signal through a
current limiting resistor to forward bias the individual anode terminals a to g.
Common Anode 7-segment Display
In this type of display, all the anode connections of the LED segments are connected together to logic
1. The separate segments are lightened by applying of the logic 0 or LOW signal through a current
limiting resistor to the cathode of the particular segment a to g.
Q-3. Write a c program to display alphanumeric characters on common cathode seven
segment led.[0-9,A-F]
Ans:
#include<r e g 5 2 . h>
void msdelay ( int d e l a y )
{
int i , j ;
for ( i =0; i<=d e l a y ; i ++)
for ( j =0; j <=500; j ++)
{};
}
void main ( )
{
P1=0x00 ;
while ( 1 )
{
P1=0x07 ;
msdelay ( 1 0 0 ) ;
}
}
Q-4. Write a c program to display alphanumeric characters on common anode seven
segment led.[0-9,A-F]
Ans:
#include<r e g 5 2 . h> //To show number 7 u s i n g common anode SSD
void msdelay ( int d e l a y ) // Delay Function
{
2
int i , j ;
for ( i =0; i<=d e l a y ; i ++)
for ( j =0; j <=500; j ++)
{};
}
void main ( )
{
P1=0x11 ; //LEDs O f f Initially
while ( 1 ) // I n f i n i t e Loop
{
P1=0xF8 ; // To show Number 7
msdelay ( 1 0 0 ) ; // C a l l msdelay F u c t i o n
}
}
Q-5. Write a c program to display sequential alphanumeric characters on common
cathode seven segment led.[0-9,A-F]
Ans:
#include<r e g 5 2 . h>
void msdelay ( int d e l a y )
{
int i , j ;
for ( i =0; i<=d e l a y ; i ++)
for ( j =0; j <=500; j ++)
{};
}
int a [ 1 6 ] = {0xBF , 0 x06 , 0 x5B , 0 x4F , 0 x66 , 0 x6D , 0 x7D , 0 x07 , 0 x7F , 0 x6F , 0 x77 , 0 x7F , 0 x39 , 0 xB
void main ( )
{
P1=0x00 ;
while ( 1 )
{
int i ;
for ( i =0; i <16; i ++)
{
P1= a [ i ] ;
msdelay ( 1 0 0 ) ;
}
}
}
Q.6. Make table for common cathode seven segment LED for alphanumeric. .[0-9,A-F]
3
Character 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
A 1 1 1 0 1 1 1
b 0 0 1 1 1 1 1
C 1 0 0 1 1 1 0
d 0 1 1 1 1 0 1
E 1 0 0 1 1 1 1
F 1 0 0 0 1 1 1