Write a program to sense the temperature of the room and to display it on the seven segment.


#include<8051.h>
void bcd(unsigned char d);
unsigned char adc_read();
unsigned char d;
unsigned char j,m,e;
void delay(unsigned int i)
{
while(i!=0)
{
i–;
}
}
unsigned char k;
void bcd(unsigned char d)
{

unsigned char j,m,e;
d=(k/10)*6+k;
j=d&0x0f;
m=j|0x70;
P0=m;
delay(200);
m=d>>4;
e=m|0xb0;
P0=e;
delay(200);
}
unsigned char adc_read()
{
P3_2=0;
P3_2=1;
while(P3_5==1)
{
d=P2;
}
return d;
}

void main()
{
P0=0x00;
P2=0xff;
while(1)
{
d=adc_read();
bcd(d);
}
}

Add Comment