当前位置:首页 > 毕业设计(论文)基于at89c51单片机温湿度显示报警系统设计
附录
[%RH]
if(rh_true>100)rh_true=100; //cut if the value is outside of if(rh_true<0.1)rh_true=0.1; //the physical possible range
*p_temperature=t_C; //return temperature [C] *p_humidity=rh_true; //return humidity[%RH] }
/**************第二部分SHT10设置 END*****************************/
/***************************主函************************************/ void main(void) {
value humi_val,temp_val;
unsigned char error,checksum,i;
LcdRw=0;
led1=0; led2=0; start=0;
s_connectionreset(); welcome();//显示欢迎画面 delay(2000);
LCD_Initial();
while(1) { error=0;
error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP); if(error!=0)
第41页(共43页)
基于单片机温湿度显示报警系统设计
s_connectionreset(); //in case of an error: connection reset
else {
humi_val.f=(float)humi_val.i; //converts integer to float
temp_val.f=(float)temp_val.i; //converts integer to float calc_sht90(&humi_val.f,&temp_val.f); //计算湿度与温度
GotoXY(0,0);//
Print(\
GotoXY(0,1);
Print(\
zhuanhuan(temp_val.f); //转换温度为uchar方便液晶显示
GotoXY(5,0);
str[5]=0xDF;//℃的符号
str[6]=0x43;
str[7]='\\0';
Print(str);
if( temp_val.f>TEMPUP-1 || temp_val.f led1=1; else led1=0; zhuanhuan(humi_val.f);//转换湿度为uchar方便液晶显示 GotoXY(5,1); str[5]='%';//%的符号 str[6]='\\0';//字符串结束标志 Print(str); if( humi_val.f>HUMUP-1 || humi_val.f led2=1; else 第42页(共43页) 附录 led2=0; } delay_n10us(80000); //延时约0.8s } } 第43页(共43页)
共分享92篇相关文档