基于单片机的智能火灾报警系统设计源程序代码研究报告.doc

基于单片机的智能火灾报警系统设计源程序代码研究报告.doc

#include reg52.h //调用单片机头文件 #define uchar unsigned char //无符号字符型 宏定义 变量范围0~255 #define uint unsigned int //无符号整型 宏定义 变量范围0~65535 #include intrins.h #include lcd1602.h #include eeprom52.h sbit CS=P2^4; //CS定义为P2口的第4位脚,连接ADC0832CS脚 sbit SCL=P2^3; //SCL定义为P2口的第3位脚,连接ADC0832SCL脚 sbit DO=P2^2; //DO定义为P2口的第2位脚,连接ADC0832DO脚 sbit dq = P2^0; //18b20 IO口的定义 sbit beep = P3^2; //蜂鸣器IO口定义 uint temperature,s_temp ; //温度的变量 uchar yanwu,s_yanwu; //烟物等级 uchar shoudong; //手动报警键 bit flag_300ms ; uchar key_can; //按键值的变量 uchar menu_1; //菜单设计的变量 bit key_500ms ; uchar phone1_i = 0; //电话号码是多少位 uchar phone2_i = 0; //电话号码是多少位 uchar phone1_call[11]={ }; uchar phone2_call[11]={ }; uchar dis_smg[11]; /***********************1ms延时函数*****************************/ void delay_1ms(uint q) { uint i,j; for(i=0;iq;i++) for(j=0;j120;j++); } #include gsm.h /***************把数组清空**********************/ void clear_shuzu(uchar *p,uchar num) { for(i=0;inum;i++) p[i] = ; } /******************把数据保存到单片机内部eeprom中**写电话号码****************/ void write_eeprom() //数据保存 { SectorErase(0x2000); for(i=0;i11;i++) byte_write(0x2000 + i,phone1_call[i]); byte_write(0x2012,phone1_i); byte_write(0x2013,phone2_i); byte_write(0x2014, s_temp); byte_write(0x2015,s_yanwu); byte_write(0x2016,a_a); byte_write(0x2020,phone2_call[0]); byte_write(0x2021,phone2_call[1]); byte_write(0x2022,phone2_call[2]); byte_write(0x2023,phone2_call[3]); byte_write(0x2024,phone2_call[4]); byte_write(0x2025,phone2_call[5]); byte_write(0x2026,phone2_call[6]); byte_write(0x2027,phone2_call[7]); byte_write(0x2028,phone2_call[8]); byte_write(0x2029,phone2_call[9]); byte_write(0x2030,phone2_call[10]); } /******************把数据从单片机内部eeprom中读出来**读电话号码***************/ void read_eeprom() { for(i=0;i11;i++) phone1_call[i] = byte_read(0x2000+i); phone1_i = byte_read(0x2012); phone2_i = byte_read(0x2013); s_temp = byte_read(0x2014); s_yanwu = byte_read(0x201

文档评论(0)

1亿VIP精品文档

相关文档