Writa a program to sense the temperature of the room and display it on the LCD.


#include<8051.h>
void lcd_init();
void lcd_cmd(unsigned char d);
void display(unsigned char d);
unsigned char adc_read();
void ascii(unsigned char k);
unsigned char f;
void delay(unsigned int i)

{
while(i!=0)
{
i–;
}
}
void lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x0c);
}
void lcd_cmd(unsigned char d)
{
P1=d;
delay(300);
P3_3=0;
P3_4=1;
P3_4=0;
}
void lcd_display(unsigned char d)
{
P1=d;
delay(300);
P3_3=1;
P3_4=1;
P3_4=0;
}
unsigned char adc_read()
{

P3_2=0;
P3_2=1;
while(P3_5==1)
{
f=P2;
}
return f;
}
void ascii(unsigned char k)
{
unsigned char t;
t=k/10;
t=t+48;
lcd_cmd(0x80);
display(t);
t=t%10;
t=t+48;
display(t);
}
unsigned char e;
void main()
{
P2=0xff;
P1=0x00;
lcd_init();
lcd_cmd(0x80);
e=adc_read();
ascii(e);
}

Add Comment