HS1101和NE555的湿度计

#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="HUMI: %RH";
sbit lcdrs=P2^4;
sbit lcdrw=P2^5;
sbit lcde=P2^6;
uchar num;
uchar tem0,tem1,humi;

uchar temp0,temp1;

uint f=0;

void timer0() interrupt 1
{
EA =0;
TR0=0;
TR1=0;

TL0=0xFF;    
TH0=0x4B;

tem0=TL1;   
tem1=TH1;
TL1=0x00;    
TH1=0x00;


TR0=1;
TR1=1;
EA=1;

}

void timer1() interrupt 3

{

EA =0;
TR0=0;
TR1=0;

TL0=0x00;   
TH0=0x4C;
TL1=0x00;   
TH1=0x00;

TR0=1;
TR1=1;
EA=1;

}

void Init_timer()
{
TMOD=0x51;

TL0=0x00;

TH0=0x4C;

TL1=0x00;

TH1=0x00;
ET0=1;

ET1=1;

EA=1;

TR0=1;

TR1=1;
}

void tran()
{
f=tem1;
f=(f< f=f*20;
if((5623 {
if((6734 {temp0=0;temp1=(6852-f)*10/118;}
if((6618 {temp0=1;temp1=(6734-f)*10/116;}
if((6503 {temp0=2;temp1=(6618-f)*10/115;}
if((6388 {temp0=3;temp1=(6503-f)*10/115;}
if((6271 {temp0=4;temp1=(6388-f)*10/117;}
if((6152 {temp0=5;temp1=(6271-f)*10/119;}
if((6029 {temp0=6;temp1=(6152-f)*10/123;}
if((5901 {temp0=7;temp1=(6029-f)*10/128;}
if((5766 {temp0=8;temp1=(5901-f)*10/135;}
if((5623 {temp0=9;temp1=(5766-f)*10/143;}
}
else
{
temp0=0;temp1=0;
}
}
void delay(uint t)
{
uchar j;
for(;t>0;t--)
for(j=19;j>0;j--);
}
void write_com(uchar com)
{
lcdrw=0;
lcdrs=0;
P0=com;
delay(10);
lcde=1;
delay(20);
lcde=0;
}
void write_date(uchar date)
{
lcdrw=0;
lcdrs=1;
P0=date;
delay(10);
lcde=1;
delay(20);
lcde=0;
}
void LCDinit()
{
lcde=0;
lcdrw=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void LCD_disp_string(uchar x,uchar y,uchar *p)
{
uchar address;
if(x==0)
address=0x80+y;
write_com(address);
while(*p>0)
{
write_date(*p);
p++;
}
}

void LCD_value(uchar x,uchar y,float f)
{
unsigned char str[15];

sprintf(str,"%.1f",f);
LCD_disp_string( x, y, str);

}

void main()
{
LCDinit();
Init_timer();
humi=0;
while(1)
{
tran();
temp0&=0x0F;
temp1&=0x0F;
temp0=temp0<<4;
humi=temp0|temp1;

LCD_value(0,6,humi);

   write_com(0x80);
   for(num=0;num<14;num++)
   {
     write_date(table[num]);

   }  
}

}
图片说明

用HS1101和NE555做的湿度计怎么仿真不出数值