7-Segment Interfacing With 8051 (AT89s52,LM35,ADC0804)
by sandeep jagdev in Circuits > Electronics
4169 Views, 4 Favorites, 0 Comments
7-Segment Interfacing With 8051 (AT89s52,LM35,ADC0804)
This time i show you to how to use 7 segment with AT89S52 and also interfacing of ADC0804 and temperature sensor with 8051.It is truly simple circuit .let gets started:
Hardware Setup:
Component Required:
7 segment LED (4) common Anode
ADC0804.
Resistors 10K.
Temperature sensor LM35.
Micro-controller AT89S52.
Crystal Oscillator(11.0592MHz)
Transistor (BC558 or BC557)
Capacitor 22pf
ULN2803
WHY I AM USING COMMON ANODE LED:
In case of common anode LED internal pin of all LED of 7-segment are internally connected so it can directly connected to 5 volts.The output current provide by 8051 is too low to drive the LED directly. So a current driver ic can be used which is ULN2803. but if we common cathode LED all pins of 7-segment are directly connected to 8051 so it can not provide enough current to drive LED.
NOTE : For Common Anode LED BC557 or BC558 (PNP) transistors are used .
For Common cathode LED BC547 orBC548 (NPN) transistors are used.
Software Setup :
All programming done in KEIL4.
Program for common anode LED:
#include <REGX51.h>
#define seg_data P0
sbit cs=P1^0;
sbit rd=P1^1;
sbit wr=P1^2;
sbit intr=P1^3;
sbit seg1=P1^4;
sbit seg2=P1^5;
sbit seg3=P1^6;
void delay();
void display_digit(int);
void main()
{
unsigned int Adcvalue,Adcvalue1,x;
char ch1,ch2,ch3;
seg1=seg2=seg3=1;
{
while(1)
{
cs=0;
rd=1;
wr=0;
wr=1;
if(intr==1)
{
cs=0;
rd=0;
Adcvalue=P2;
for(x=0;x<=100;x++){
if(Adcvalue>9){
ch1=Adcvalue/100;
display_digit(ch1);
P3=0xfe;
delay();
P3=0xff;
delay();
Adcvalue1=Adcvalue%100;
ch2=Adcvalue1/10;
display_digit(ch2);
P3=0xfd;
delay();
P3=0xff;delay();
ch3=Adcvalue1-(ch2*10);
display_digit(ch3);
P3=0xfb;
delay();
P3=0xff;
delay();
}
}
}
}
}
}
void display_digit(int c)
{
switch(c)
{ case 0: P0=0x3f;
break;
case 1: P0=0x06;
break;
case 2: P0=0x5b;
break;
case 3: P0=0x4f;
break;
case 4:P0=0x66;
break;
case 5: P0=0x6d;
break;
case 6:P0=0x7d;
break;
case 7:P0=0x07;
break;
case 8:P0=0x67;
break;
case 9:P0=0x40;
break;
return;
}
}
void delay()
{
unsigned int b;
for (b=0;b<=400;b++);
}
YOU CAN DOWNLOAD CODE FROM HERE :