欢迎来到天天文库
浏览记录
ID:9846574
大小:27.50 KB
页数:5页
时间:2018-05-12
《基于单片机家用电器电话遥控器》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、基于单片机的家用电器电话遥控器系统源程序//pcb管脚改动,P2.0=STD#include//ISD1420地址口使用P0口#include#includesbitCS=P1^0;sbitPL=P1^2;//ISD1420控制键sbitPNR=P1^4;sbitTXEN=P1^5;sbitKEY1=P1^6;sbitKEY2=P1^7;sbitDO=P3^0;sbitDI=P3^1;sbitLED_Y=P3^2;//黄灯sbitLED_R=P3^3;//红灯sbitLED_G=P3^4;/
2、/绿灯sbitJK1=P3^5;//继电器1sbitJK2=P3^6;//继电器2sbitJK3=P3^7;//继电器3sbitQ0=P2^4;/*cm8870*/sbitQ1=P2^3;sbitQ2=P2^2;sbitQ3=P2^1;sbitSTD=P2^0;sbitTEL_RING=P2^5;/*振铃判断*/sbitTEL_LED=P2^6;sbitTEL_PHONE=P2^7;/*摘挂机*/unsignedintDT,DT2,DT3,NT,NR,FLAG,PW_ERROR;//NR振铃计数,FLAG置判断标志unsignedintcodeP
3、W[6]={1,2,3,4,5,6};//登陆密码voidmDelay(unsignedintDelaytime){unsignedinti;for(;Delaytime>0;Delaytime--){for(i=0;i<255;i++){;}5}}voidV_START()//欢迎进入小灯控制系统00H-13H2.5s{P0=0x00;mDelay(10);PL=0;mDelay(2480);PL=1;}voidV_PW()//请输入6位密码,13H-22H1.875s{P0=0x13;mDelay(10);PL=0;}voidV_PWR()/
4、/密码正确22H-2cH1.25s{P0=0x22;mDelay(10);PL=0;mDelay(1300);PL=1;}voidV_PWE()//密码错误,再见2cH-3dH2.125s{P0=0x2c;mDelay(10);PL=0;mDelay(2200);PL=1;}voidV_LED()//“点亮小灯请按1,熄灭小灯请按2,退出系统请按3”3dh-65h5s{NR=1;DT=0;DT2=0;NT=1;while(NR){P0=0x3d;mDelay(10);PL=0;if(STD){PL=1;NR=0;}if(DT>200){FLAG=
5、9;PL=1;NR=0;}if(DT2>110){PL=1;while(NT){if(STD)NT=0;};PL=0;}}NR=1;}voidV_LEDON()//小灯已点亮65H-71H1.5s{P0=0x65;mDelay(10);PL=0;mDelay(1800);PL=1;}voidV_LEDOFF()//小灯已熄灭71H-7eH1.75s{P0=0x71;mDelay(10);PL=0;5mDelay(1950);PL=1;}voidV_TIMEOUT()//对不起,您超时了,再见7fH-93H2.5s{P0=0x7f;mDelay(1
6、0);PL=0;mDelay(2700);PL=1;}voidRING(unsignedintAA)//振铃{NR=1;DT=0;while(NR){if(TEL_RING==0){++NR;mDelay(3000);}//振铃判断NR,振铃5秒/次if(NR>AA){FLAG=1;NR=0;}//置摘机标志,退出RINGif(DT>200)NR=0;//若启动RING后10S内无振铃,则退出RING}}voidPASSWORD()//密码{unsignedinti,DQ,PWAA[6];NR=1;DT=0;i=0;PW_ERROR=0;V_PW
7、();while(NR){if(STD){PL=1;DT=0;while(STD){if(DT>200){FLAG=9;PL=1;NR=0;}}DQ=(int)Q0+(int)Q1*2+(int)Q2*4+(int)Q3*8;PWAA[i++]=DQ;}if(i==6){for(i=0;i<6;i++){if(PWAA[i]!=PW[i])PW_ERROR=1;}//密码错误if(PW_ERROR==1){V_PWE();PW_ERROR=0;FLAG=0;NR=0;}//密码错误退出else{V_PWR();FLAG=2;NR=0;}//密码正
8、确}if(DT>200){FLAG=9;PL=1;NR=0;}}}voidC_LED(){unsignedintQQ;NR=1;DT=0
此文档下载收益归作者所有