資源描述:
《智能火災(zāi)報(bào)警系統(tǒng)設(shè)計(jì).doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、智能火災(zāi)報(bào)警系統(tǒng)仿真源程序#include#include"eepom52.h"#defineucharunsignedchar#defineuintunsignedint#include//數(shù)碼管段選定義0123456789ucharcodesmg_du[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};//斷碼//數(shù)碼管位選定義u
2、charcodesmg_we[]={0x7f,0xbf,0xdf,0xef};//ucharcodesmg_we[]={0xfe,0xfd,0xfb,0xf7};uchardis_smg[8]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8};ucharsmg_i=3;//顯示數(shù)碼管的個(gè)位數(shù)sbitSCL=P3^4;//SCL定義為P1口的第3位腳,連接ADC0832SCL腳sbitDO=P3^3;//DO定義為P1口的第4位腳,連接ADC0832DO腳sbitCS
3、=P3^2;//CS定義為P1口的第4位腳,連接ADC0832CS腳sbitdq=P3^5;//18b20IO口的定義sbitbeep=P3^6;//蜂鳴器IO口定義uinttemperature,s_temp;//溫度的變量uchardengji,s_dengji;//煙物等級(jí)ucharshoudong;//手動(dòng)報(bào)警鍵uinthuoyan;bitflag_300ms;ucharkey_can;//按鍵值的變量ucharmenu_1;//菜單設(shè)計(jì)的變量bitflag_lj_en;//按鍵連加使能bi
4、tflag_lj_3_en;//按鍵連3次連加后使能加的數(shù)就越大了ucharkey_time,flag_value;//用做連加的中間變量bitkey_500ms;ucharflag_clock;ucharzd_break_en,zd_break_value;//自動(dòng)退出設(shè)置界面uchara_a;/***********************1ms延時(shí)函數(shù)*****************************/voiddelay_1ms(uintq){uinti,j;for(i=0;i5、++)for(j=0;j<120;j++);}/***********************小延時(shí)函數(shù)*****************************/voiddelay_uint(uintq){while(q..);}/******************把數(shù)據(jù)保存到單片機(jī)內(nèi)部eepom中******************/voidwrite_eepom(){SectorErase(0x2000);byte_write(0x2000,s_temp);byte_write(0x2001
6、,s_dengji);byte_write(0x2060,a_a);}/******************把數(shù)據(jù)從單片機(jī)內(nèi)部eepom中讀出來*****************/voidread_eepom(){s_temp=byte_read(0x2000);s_dengji=byte_read(0x2001);a_a=byte_read(0x2060);}/**************開機(jī)自檢eepom初始化*****************/voidinit_eepom(){read_eep
7、om();//先讀if(a_a!=1)//新的單片機(jī)初始單片機(jī)內(nèi)問EEPOM{s_temp=50;s_dengji=5;a_a=1;write_eepom();}}/***********************18b20初始化函數(shù)*****************************/voidinit_18b20(){bitq;dq=1;//把總線拿高delay_uint(1);//15usdq=0;//給復(fù)位脈沖delay_uint(80);//750usdq=1;//把總線拿高等待dela
8、y_uint(10);//110usq=dq;//讀取18b20初始化信號(hào)delay_uint(20);//200usdq=1;//把總線拿高釋放總線}/*************寫18b20內(nèi)的數(shù)據(jù)***************/voidwrite_18b20(uchardat){uchari;for(i=0;i<8;i++){//寫數(shù)據(jù)是低位開始dq=0;//把總線拿低寫時(shí)間隙開始dq=dat&0x01;//向18b20總線寫數(shù)據(jù)了delay_uint(5);//