资源描述:
《基于单片机温度报警系统+proteus仿真》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、WORD格式整理#include#include#defineucharunsignedchar#defineuintunsignedint#definedelayNOP(){_nop_();_nop_();_nop_();_nop_();}sbitHI_LED=P2^3;//高温,低温白净闪烁LEDsbitLO_LED=P2^6;sbitDQ=P3^3;//DS18B20数据线sbitBEEP=P3^7;//报警sbitRS=P2^0;sbitRW=P2^1;sbi
2、tEN=P2^2;sbitK1=P1^7;//正常显示温度,越界时报警sbitK2=P1^4;//显示报警温度sbitK3=P1^1;//查看ROMCODEucharcodeRomCodeStr[]={"--ROMCODE--"};ucharRomCode[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//64位ROMCODEucharcodeTemp_Disp_Title[]={"CurrentTemp:"};ucharCurrent_Temp_Display_
3、Buffer[]={"TEMPE:"};ucharcodeTemperature_Char[8]={0x0c,0x12,0x12,0x0c,0x00,0x00,0x00,0x00};//温度示字符ucharcodeAlarm_Temp[]={"ALARMTEMPHiLo"};ucharAlarm_HI_LO_STR[]={"Hi:Lo:"};uchartemp_data[2]={0x00,0x00};学习参考资料分享WORD格式整理uchartemp_alarm[2]={0x00,0x00};uchardi
4、splay[5]={0x00,0x00,0x00,0x00,0x00,};//温度值uchardisplay1[3]={0x00,0x00,0x00};//温度报警值ucharcodedf_Table[]={0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9};//温度小数位对照表//.......................................................//报警温度上下限(取值范围:-128~+127)(DS18B20温度范围为:-55~+125)//数组
5、中前一位为高温值,后一位为低温值//此处类型注意设为char,否则不能进行有符号数的比较charAlarm_Temp_HL[2]={70,-20};//............................................................ucharCurrentT=0;//当前读取温度整数部分ucharTemp_Value[]={0x00,0x00};//从DS18B20读取的温度值ucharDisplay_Digit[]={0,0,0,0};//待显示的各温度数位bitH
6、I_Alarm=0,LO_Alarm=0;//高低温报警标志bitDS18B20_IS_OK=1;//传感器正常标志uintTime0_Count=0;//定时器延时累加//...........................//延时//...........................voidDelayXus(intx){uchari;while(x--)for(i=0;i<200;i++);}//.......................................//忙检测bitLCD_
7、Busy_Check(){bitLCD_Status;RS=0;//寄存器选择RW=1;//读状态寄存器EN=1;//开始读DelayXus(1);LCD_Status=(bit)(P0&0x80);EN=0;returnLCD_Status;}//写LCD指令voidWrite_LCD_Command(ucharcmd){while((LCD_Busy_Check()&0x80)==0x80);//忙等待RS=0;//写选择命令寄存器学习参考资料分享WORD格式整理RW=0;//写EN=0;P0=cmd;
8、EN=1;DelayXus(1);EN=0;}//向LCD写数据voidWrite_LCD_Data(uchardat){while((LCD_Busy_Check()&0x80)==0x80);//忙等待RS=1;RW=0;EN=0;P0=dat;EN=1;DelayXus(1);EN=0;}//设置液晶显示位置voidSet_LCD_POS(ucharpos){Write_LCD_Command(pos
9、0x