click on image for clear view
component list
C program
#include
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit DQ=P2^5;
sbit output=P2^6;
void lcdcmd(unsigned char value);
void lcddata_number(unsigned char value);
void lcddata(unsigned char *value);
void lcddelay(unsigned int time);
bit reset();
void delay(int us);
bit readbit(void);
void writebit(bit dbit);
unsigned char readbyte(void);
void writebyte(unsigned char dout);
void readtemp();
unsigned char mydata1,mydata2,mydata3;
void main()
{
lcdcmd(0x38);
lcddelay(10);
lcdcmd(0x0e);
lcddelay(10);
lcdcmd(0x01);
lcddelay(10);
lcdcmd(0x06);
lcddelay(10);
lcddata("temperature");
while(1)
{
readtemp();
}
}
bit reset()
{
bit presense;
DQ=0;
delay(29);
DQ=1;
delay(3);
presense=DQ;
delay(25);
output=presense;
return(presense);
}
bit readbit(void)
{
unsigned char i=0;
DQ=0;
DQ=1;
for(i=0;i<3;i++);
return(DQ);
}
void writebit(bit Dbit)
{
unsigned char i=0;
DQ=0;
DQ=Dbit?1:0;
delay(5);
DQ=1;
}
unsigned char readbyte(void)
{
unsigned char i;
unsigned char din=0;
for(i=0;i<8;i++)
{
din=readbit()?0x01<
}
//B=din;
return(din);
}
void writebyte(unsigned char dout)
{
unsigned char i;
for(i=0;i<8;i++)
{
writebit((bit)(dout&0x01));
dout=dout>>1;
}
delay(5);
}
void readtemp()
{
unsigned char n;
unsigned char buff[9];
EA=0;
reset();
writebyte(0xcc);
writebyte(0x44);
while(readbyte()==0xff);
reset();
writebyte(0xcc);
writebyte(0xbe);
for(n=0;n<9;n++)
{
buff[n]=readbyte();
delay(100);
}
mydata1=buff[0];
delay(10);
mydata1=mydata1>>4;
mydata2=buff[1];
delay(10);
mydata2=mydata2<<4;
mydata3=mydata2mydata1;
lcddata_number(mydata3);
//lcddelay(1);
delay(2500);
EA=1;
}
void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
lcddelay(1);
en=0;
return;
}
void lcddata_number(unsigned char value)
{
char data1;
lcdcmd(0x8c);
delay(1000);
B=value;
data1=value%10;
value=value/10;
if(value>9)
{
ldata=1+0x30;
for(;value!=0;)
{
data1 =value%10;
ldata=data1+0x30;
rs=1;
rw=0;
en=1;
lcddelay(100);
en=0;
ldata=value%10+0x30;
rs=1;
rw=0;
en=1;
lcddelay(10);
en=0;
}
}
else
{
ldata=value+0x30;
lcddelay(10);
rs=1;
rw=0;
en=1;
lcddelay(10);
en=0;
}
ldata=data1+0x30;
rs=1;
rw=0;
en=1;
lcddelay(100);
en=0;
ldata='\0';
rs=1;
rw=0;
en=1;
lcddelay(100);
en=0;
return;
}
void lcddata(unsigned char *value)
{
char i;
for(i=0;value[i]!='\0';i++)
{
ldata=value[i];
rs=1;
rw=0;
en=1;
lcddelay(100);
en=0;
}
return;
}
void lcddelay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<=time;i++)
{
for(j=0;j<=1000;j++);
}
}
void delay(int us)
{
int i;
for(i=0;i
Discription
This circuit is useful for monitor industrial temperature upto 200 degees c
for more details please mail to sekharstuff@yahoo.co.in
No comments:
Post a Comment