return dat;
}
//------------------------------------------ void lcd2301() //显示字
{ BYTE i; LCD_send_command(0x80+0x40); for(i=0;i<4;i++) { LCD_send_data(t[i]); delay(15);
}
LCD_send_command(0x80+0x4a); for(i=0;i<4;i++)
{ LCD_send_data(rt[i]); delay(15);
}}
//-------------------------------------------- void display_2301() //显示数据
{ BYTE i,j; tempra_2301[0] = tem_2301/100+0x30; tempra_2301[1] = tem_2301/10+0x30; tempra_2301[2] = 0x2e;
tempra_2301[3] = tem_2301+0x30;
- 21 -
humini_2301[0] = hum_2301/100+0x30; humini_2301[1] = hum_2301/10+0x30; humini_2301[2] = 0x2e;
humini_2301[3] = hum_2301+0x30; LCD_send_command(0x80+0x44); for(i=0;i<4;i++)
{ LCD_send_data(tempra_2301[i]); delay(15);
}
LCD_send_command(0x80+0x40+12); for(j=0;j<4;j++)
{ LCD_send_data(humini_2301[j]); delay(15);
}}
//------------------------------------ void readdata_2301() { BYTE hum_h,hum_l; BYTE tem_h,tem_l; BYTE check; BYTE checkdata; WORD
tem_hum,tem_tem;
check_rt();
- 22 -
hum_h = read_byte_2301(); hum_l = read_byte_2301(); tem_h = read_byte_2301(); tem_l = read_byte_2301(); check = read_byte_2301(); tem_hum = hum_h<<8; tem_tem = tem_h<<8; hum_2301 = tem_hum|hum_l; tem_2301 = tem_tem|tem_l;
checkdata = hum_h + hum_l + tem_h + tem_l; // if(check==checkdata) // hum = 5;
、
P3M1 = 0X00; P3M0 = 0X00;
}
//---------555----------------------------- sbit date = P3^5;
BYTE readbit()//接收一位数据 { BYTE WEI; TH0 = 0; TL0 = 0;
EA = 0;
- 23 -
while(!date); TR0 = 1; while(date); TR0 = 0; EA = 1; if(TL0>30)
WEI = 1;
else WEI = 0; return WEI;
}
//------------------------------------------- BYTE read_byte() //接收一个字节{ BYTE dat = 0;
BYTE temp; BYTE a; int i = 7; while(i>=0) { a = readbit(); temp = a<
}
- 24 -
return dat;
}
//----------------------------------------------- void display_555()
//显示数据
{ BYTE i; tempra[0] = tem/100+0x30; tempra[1] = tem/10+0x30; tempra[2] = 0x2e; tempra[3] = tem+0x30; humini[0] = hum/10+0x30; humini[1] = hum+0x30; LCD_send_command(0x80+4); for(i=0;i<4;i++)
{ LCD_send_data(tempra[i]); delay(15);
}
LCD_send_command(0x80+12); for(i=0;i<2;i++)
{ LCD_send_data(humini[i]); delay(15);
}}
//----------------------
- 25 -