seven segment is most common output device with a limitation that only digits and few characters can be displayed ex- you can not display 'k'. in seven segment array of LEDs are arranged in a special pattern. as shown in figure 7 leds a-h is assigned for special digit/character while eighth LED 'h' is used to display the dot.particular LED glows when its corresponding pin goes high
seven segment is mostly available in 10 pin package and 8 of these used as data pins while the 2 middle pins are common and internally shorted. seven segment can be categorized as-->
a)Common Cathode Seven Segment Display
b)Common Anode Seven Segment Display
WORKING
we are here working on common cathode seven segment and if you are working on more than one segment you need to latch data suitably otherwise data would be misinterpreted .for this you need to enable only one seven segment display at a time.
Proteus Design
transistor acts as switch
transistor(on-state)
transistor(off-state)
CODE
As you know transistor can acts as switch. using this property of transistor we enable single 7-seg at a particular time.after receiving data(character 'H') at unit place turn off it.our next step is turn on second transistor to latch data(character 'R') to be displayed at tens place.
Complete Code
#include <REGX51.H>
#define segment P2
sbit unitcmntr=P3^0;
sbit tenscmntr=P3^1;
unsigned char unit,tens;
void display();
void delay();
void main()
{
unit=0Xf7;
tens=0X76;
while(1)
{
display();
}
}
void display()
{
segment=unit;
unitcmntr=1;
delay();
unitcmntr=0;
segment=tens;
tenscmntr=1;
delay();
tenscmntr=0;
}
void delay()
{
int i;
for(i=0;i<500;i++)
{
}
}
Category: