完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include < reg51.h > #include < intrins.h > #define uchar unsigned char #define uint unsigned int ***it DQ=P2^7; //定义DS18B20端口DQ ***it LCD_RS=P3^4; ***it LCD_RW=P3^6; ***it LCD_EN=P3^7; ***it ST=P0^0; ***it SH=P0^1; ***it Sjia=P3^2; ***it Sjian=P3^3; ***it WBJ=P2^6; ***it HBJ=P2^5; uchar code str1[]={"wend:"}; uchar code str2[]={"shid:"}; uchar data disdata1[6]; uchar data disdata2[4]; uint tvalue;//温度值 uchar tflag;//温度正负标志 uint tem0,tem1; uint temp0,temp1; uint f=0; int hhhh=0; int tsheding=20;//设置温度值 int hsheding=40;//设置湿度值 void zhongd0() interrupt 0//外部中断0:加设置 { if(ST==1) { tsheding++;//温度值加1 } if(SH==1) { hsheding++;//湿度值加1 } } void zhongd1() interrupt 2//外部中断1:减设置 { if(ST==1) { tsheding--;//温度值减1 } if(SH==1) { hsheding--;//湿度值减1 } } void timer0() interrupt 1 //T0定时中断 { TR0=0; TR1=0; TL0=0xB0; TH0=0x3C; tem0=TL1; tem1=TH1; TL1=0x00; TH1=0x00; TR0=1; TR1=1; } void timer1() interrupt 3 //T1定时中断 { TR0=0; TR1=0; TL0=0xB0; TH0=0x3C; TL1=0x00; TH1=0x00; TR0=1; TR1=1; } void init_timer() { TMOD=0x51; TL0=0xB0; TH0=0x3C; TL1=0x00; TH1=0x00; TR0=1; TR1=1; } void TPanDuan() { uint k=tvalue/(10); if(tflag==0) { if((k>(tsheding*1.2))||(k<(tsheding*0.8))) { WBJ=1; } else { WBJ=0; } } else { if((k>tsheding*(-1.2))||(k WBJ=1; } else { WBJ=0; } } } void delay1ms(uint ms) { uint i,j; for(i=0;i } void wr_com(uchar com) { delay1ms(1); LCD_RS=0; LCD_RW=0; LCD_EN=0; P1=com; delay1ms(1); LCD_EN=1; delay1ms(1); LCD_EN=0; } void wr_dat(uchar dat) { delay1ms(1); LCD_RS=1; LCD_RW=0; LCD_EN=0; P1=dat; delay1ms(1); LCD_EN=1; delay1ms(1); LCD_EN=0; } void lcd_init() { wr_com(0x38);delay1ms(1); wr_com(0x08);delay1ms(1); wr_com(0x01);delay1ms(1); wr_com(0x06);delay1ms(1); wr_com(0x0c);delay1ms(1); } void display(uchar*p) { while(*p!=' |