![智能家居控制系統(tǒng)C程序_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/baa6f297-d458-4bc2-ba29-a3c25aa65e3e/baa6f297-d458-4bc2-ba29-a3c25aa65e3e1.gif)
![智能家居控制系統(tǒng)C程序_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/baa6f297-d458-4bc2-ba29-a3c25aa65e3e/baa6f297-d458-4bc2-ba29-a3c25aa65e3e2.gif)
![智能家居控制系統(tǒng)C程序_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/baa6f297-d458-4bc2-ba29-a3c25aa65e3e/baa6f297-d458-4bc2-ba29-a3c25aa65e3e3.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、.智能家居控制系統(tǒng)C程序日期:2010-03-03 來源:本站編輯 作者:admin 字體:大 中 小 (投遞新聞) *include bit r_flag; enum eepromtype M2401,M2402,M2404,M2408,M2416,M2432,M2464,M24128,M24256; extern bit RW24*(unsigned char *DataBuff,unsigned char ByteQuantity,unsigned int Address, unsigned char ControlByte,enum eepromtype EepromType); sb
2、it key = P20; bit key_flag; sbit dog = P07; sbit LED = P00; sbit TELA = P36; sbit TEL = P37; sbit RING = P32; sbit switching =P04; unsigned char mode; bit passwordflag; unsigned char password6; unsigned char passwordtest6; void dlms(unsigned int x); void reset(void); void open(void); /* / / INT1中斷服務(wù)
3、程序 / /* / unsigned char ring_fluctuation; unsigned char ring_count; bit ring_flag; void service_int0() interrupt 0 using 1 if(ring_fluctuation5) EX0=0;/INT1_OFF; ring_dlsm+; if(ring_dlsm=20)/等待一秒 ring_dlsm=0; EX0=1;/INT1_ON; ring_fluctuation=0; ring_count+;/震鈴次數(shù) if(ring_flag)/有效振鈴 if(ring_count=6) r
4、ing_count=7; mode=1; else/無效振鈴 if(ring_count2) ring_reset_time=800; if(ring_count=2)|(ring_count=1) ring_time+; if(ring_time=200) ring_flag=1; if(ring_count0)&(ring_count0) ring_reset_time+; if(ring_reset_time=1100)/55s reset(); LED=0; dlms(100); LED=1; dlms(100); LED=0; dlms(100); LED=1; dlms(100);
5、 LED=0; dlms(100); LED=1; dlms(100); LED=0; dlms(100); LED=1; dlms(100); LED=0; dlms(100); LED=1; dlms(100); LED=0; dlms(100); LED=switching; /* / / INT1中斷服務(wù)程序 / /* / unsigned char DTMF; void service_int1() interrupt 2 using 1 EX1=0; DTMF=P1; DTMF=DTMF4; void main(void) TMOD=0x11; TH1=0x3c; TL1=0xb0
6、; TR1=1; ET1=1; IT0=1; EX0=1; IT1=0; EX1=1; reset(); EA=0; r_flag=RW24*(password,6,0x0000,0xa1,M2402);/R if(P2_0=0) dlms(20); if(P2_0=0) ring_flag=1; mode=1; passwordflag=1; ring_count=7; ring_fluctuation=6; EA=1; while(1) open(); dog=dog; switch(mode) case 0:; break; case 1: TEL=1; LED=0;/ dlms_tim
7、e=0; ring_reset_time=0; while(dlms_time40) dlms(1); TELA=TELA; ring_reset_time=0; LED=1;/ TELA=0; mode+; DTMF=255; EX1=1; LED=switching; break; case 2:/password if(DTMF!=255) passwordtest0=DTMF; if(INT1=1) dlms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; dlms_time=0; while(dlms_time10) dl
8、ms(2); TELA=TELA; EX1=1; TELA=0; break; case 3:/password if(DTMF!=255) passwordtest1=DTMF; if(INT1=1) dlms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; dlms_time=0; while(dlms_time10) dlms(2); TELA=TELA; EX1=1; TELA=0; break; case 4:/password if(DTMF!=255) passwordtest2=DTMF; if(INT1=1) dl
9、ms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; dlms_time=0; while(dlms_time10) dlms(2); TELA=TELA; EX1=1; TELA=0; break; case 5:/password if(DTMF!=255) passwordtest3=DTMF; if(INT1=1) dlms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; dlms_time=0; while(dlms_time10) dlms(2); TELA=
10、TELA; EX1=1; TELA=0; break; case 6:/password if(DTMF!=255) passwordtest4=DTMF; if(INT1=1) dlms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; dlms_time=0; while(dlms_time2); if(INT1=1) DTMF=255; mode+; /EX1=1; break; case 8: if(passwordflag=0) if(passwordtest0=password0)&(passwordtest1=passw
11、ord1)&(passwordtest2=password2)&(passwordtest3=password3)&(passwordtest4=password4)&(passwordtest5=password5) mode+; dlms_time=0; else reset(); else dlms_time=0; while(dlms_time10) dlms(2); TELA=TELA; TELA=0; password0=passwordtest0; password1=passwordtest1; password2=passwordtest2; password3=passwo
12、rdtest3; password4=passwordtest4; password5=passwordtest5; EA=0; r_flag=RW24*(password,6,0x0000,0xa0,M2402);/W EA=1; reset(); break; case 9: while(dlms_time20) dlms(1); TELA=TELA; while(dlms_time25) while(dlms_time45) dlms(1); TELA=TELA; TELA=0; EX1=1; mode+; break; case 10: switch(DTMF) case 1: if(
13、ring_reset_time1050) dlms_time=0; switching=0; LED=0; while(dlms_time10) while(dlms_time20) dlms(2); TELA=TELA; while(dlms_time30) while(dlms_time40) dlms(2); TELA=TELA; TELA=0; DTMF=255; EX1=1; break; case 2: if(ring_reset_time1050) dlms_time=0; switching=1; LED=1; while(dlms_time10) while(dlms_tim
14、e20) dlms(4); TELA=TELA; while(dlms_time30) while(dlms_time40) dlms(4); TELA=TELA; TELA=0; DTMF=255; EX1=1; break; case 12: reset(); break; break; /-/ default:; /-/ void reset(void) TEL=0; TELA=0; ring_fluctuation=0; ring_count=0; ring_flag=0; ring_dlsm=0; ring_time=0; dlms_time=0; ring_reset_time=0
15、; key_flag=0; mode=0; EX1=1; DTMF=255; LED=switching; passwordflag=0; passwordtest0=255; passwordtest1=255; passwordtest2=255; passwordtest3=255; passwordtest4=255; passwordtest5=255; void open(void) if(key=0)&(key_flag=0)&(passwordflag=0) dlms_time=0; while(dlms_time10) key_flag=0; void dlms(unsign
16、ed int x) unsigned int i; while (x-0) dog=dog; for (i=0;i163;i+) ; /24c* /-START-/ /enum eepromtype M2401,M2402,M2404,M2408,M2416,M2432,M2464,M24128,M24256; /extern bit RW24*(unsigned char *DataBuff,unsigned char ByteQuantity,unsigned int Address, / unsigned char ControlByte,enum eepromtype EepromTy
17、pe); / flag=RW24*(&x,1,0x0000,0xa0,M24256);/W 24C256 / flag=RW24*(&x,1,0x0000,0xa1,M24256);/R 24C256 *include /*pragma ot(6,SIZE) *include *define ERRORCOUNT 10 sbit SDA=P27;/對應(yīng)硬件 sbit SCL=P26;/對應(yīng)硬件 enum eepromtype M2401,M2402,M2404,M2408,M2416,M2432,M2464,M24128,M24256; enum eepromtype EepromType;
18、/*/ /DataBuff為讀寫數(shù)據(jù)輸入輸出緩沖區(qū)的首址 /ByteQuantity 為要讀寫數(shù)據(jù)的字節(jié)數(shù)量 /Address 為EEPROM的片內(nèi)地址 /ControlByte 為EEPROM的控制字節(jié),具體形式為(1)(0)(1)(0)(A2)(A1)(A0)(R/W),其中R/W=1, /表示讀操作,R/W=0為寫操作,A2,A1,A0為EEPROM的頁選或片選地址; /EepromType為枚舉變量,需為M2401至M24256中的一種,分別對應(yīng)24C01至24C256; /函數(shù)返回值為一個位變量,若返回1表示此次操作失效,0表示操作成功; /ERRORCOUNT為允許最大次數(shù),若出現(xiàn)
19、ERRORCOUNT次操作失效后,則函數(shù)中止操作,并返回1 /*/ extern bit RW24*(unsigned char *DataBuff,unsigned char ByteQuantity,unsigned int Address, unsigned char ControlByte,enum eepromtype EepromType) void Delay(unsigned char DelayCount); void IICStart(void); void IICStop(void); bit IICRecAck(void); void IICNoAck(void); v
20、oid IICAck(void); unsigned char IICReceiveByte(void); void IICSendByte(unsigned char sendbyte); unsigned char data j,i=ERRORCOUNT; bit errorflag=1; while(i-) IICStart(); IICSendByte(ControlByte&0xfe); if(IICRecAck() continue; if(EepromTypeM2416) IICSendByte(unsigned char)(Address8); if(IICRecAck() c
21、ontinue; IICSendByte(unsigned char)Address); if(IICRecAck() continue; if(!(ControlByte&0x01) j=ByteQuantity; errorflag=0; /*clr errorflag while(j-) IICSendByte(*DataBuff+); if(!IICRecAck() continue; errorflag=1; break; if(errorflag=1) continue; break; else IICStart(); IICSendByte(ControlByte); if(IICRecAck() continue; while(-ByteQuantity) *DataBuff+=IICReceiveByte(); IICAck(); *DataBuff=IICReceiveByte(); /read last byte data IICNoAck(); errorflag=0;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 個人電車租車合同范本
- 公司民間借款合同范本
- 辦公裝修協(xié)議合同范例
- 公路養(yǎng)護補充協(xié)議合同范本
- 二手車銷售中心合同范本
- 健身俱樂部就業(yè)合同范本
- 勞務(wù)薪酬合同范例
- 2025年度家庭寵物養(yǎng)護保姆服務(wù)合同
- 公司如資金合同范本
- 兼職勞務(wù)合同范本乙方
- 現(xiàn)金盤點表完整版
- 病例展示(皮膚科)
- GB/T 39750-2021光伏發(fā)電系統(tǒng)直流電弧保護技術(shù)要求
- 教科版五年級科學(xué)下冊【全冊全套】課件
- 糖尿病運動指導(dǎo)課件
- 完整版金屬學(xué)與熱處理課件
- T∕CSTM 00640-2022 烤爐用耐高溫粉末涂料
- 304不銹鋼管材質(zhì)證明書
- 民用機場不停航施工安全管理措施
- 港口集裝箱物流系統(tǒng)建模與仿真技術(shù)研究-教學(xué)平臺課件
- 新教科版2022年五年級科學(xué)下冊第2單元《船的研究》全部PPT課件(共7節(jié))
評論
0/150
提交評論