家用电器远程控制 - 图文(7)

2019-03-16 15:24

//initialize the variable end

if(JREC==0)//如果跳线为接通则开始录音

{

delay(400); if(JREC==0)

{

RecVoice();//录音程序 } }

Time_Counter=0;

TimeOut_Counter=60;//60 equation the 3s TR0=0;//停止计数 while(1) {

if(Flag_Timeout) {

Flag_Timeout=0; Count++;

if(Count>2){ONPHONE=1;Count=0;TR0=0;Ring_Counter=0; Pre_Point=1;} else Flag_Startsystem=1; }

if(Flag_Startsystem) {

Flag_Startsystem=0; ONPHONE=0;//let the jx on to start work switch(Pre_Point)//选择播放哪段录音 {

case 1:P0=0x00;PLAY=1;delay(1);PLAY=0;break; case 2:P0=0x20;PLAY=1;delay(1);PLAY=0;break; case 3:P0=0x38;PLAY=1;delay(1);PLAY=0;break; case 4:P0=0x66;PLAY=1;delay(1);PLAY=0; Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s while(~Flag_Timeout);

Flag_Timeout=0;TimeOut_Counter=100;Pre_Point=3;Flag_Startsystem=1; break;

case 5:P0=0x76;PLAY=1;delay(1);PLAY=0;

Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s

while(~Flag_Timeout); Flag_Timeout=0;TimeOut_Counter=100;Pre_Point=3;Flag_Startsystem=1; break; default: break; }

}

if(Flag_Receivecode) {

Flag_Receivecode=0; //P2=Dtfm_code;

Time_Counter=0;

TimeOut_Counter=200;//200 equation the 10s TR0=1;//开始计数,看是否有超时发生 switch(Pre_Point)

{

//状态为1时统计密码并保存到相应缓冲区,当按下#号键时开始检查密码是否正确 case 1:if(Dtfm_code==0x0c)Flag_Checkpass=1;

else {

PasswordBuf[Pre_Receive]=Dtfm_code;

Pre_Receive++; } break;

//状态为2时记下要控制的家电代号

case 2:Pre_Wantcontrol=Dtfm_code;Pre_Point=3;Flag_Startsystem=1;break;

//状态为3时控制对应家电是启动(1)还是停止(0)或者返回到上一级菜单控制其它家电

case 3:if(Dtfm_code==0x01) { switch(Pre_Wantcontrol)

{

case 1: DEVICE1=0;break; case 2: DEVICE2=0;break; case 3: DEVICE3=0;break; case 4: DEVICE4=0;break; case 5: DEVICE5=0;break; case 6: DEVICE6=0;break; case 7: DEVICE7=0;break; case 8: DEVICE8=0;break; }

Pre_Point=4;Flag_Startsystem=1;

}

if(Dtfm_code==0x0a) {

switch(Pre_Wantcontrol) {

case 1: DEVICE1=1;break; case 2: DEVICE2=1;break; case 3: DEVICE3=1;break; case 4: DEVICE4=1;break; case 5: DEVICE5=1;break;

case 6: DEVICE6=1;break; case 7: DEVICE7=1;break; case 8: DEVICE8=1;break; }

Pre_Point=5;Flag_Startsystem=1;

}

if(Dtfm_code==0x0b)

{Pre_Point=2;Flag_Startsystem=1;}

if(Dtfm_code==0x09){ONPHONE=1;Count=0;TR0=0;Ring_Counter=0;

Pre_Point=1;}

default: break; }

}

if(Flag_Checkpass)//检查各位密码是否相同,如果不同则再要求输入密码

{

Flag_Checkpass=0;

for(temp=0;temp<6;temp++) {

if(PasswordBuf[temp]==SavePassword[temp])

{Flag_Startsystem=1;Pre_Point=2;} else {Pre_Point=1;Flag_Startsystem=1;Pre_Receive=0;break;} } }

} }

//当有电话铃时产生中断,如果4次电话铃没有接则启动该系统控制家电 void RINGinterrupt0(void) interrupt 0 //have a telephone ring {

Ring_Counter++;

if(Ring_Counter==4)Flag_Startsystem=1; for(temp1=0;temp1<80;temp1++) delay(1000);

}

//用来定时的计数器。判断是否有超时发生 void Time_Intp(void) interrupt 1 { TR0 = 0; }

TH0 = 0x3c; TL0 = 0xb0;

TR0 = 1;

Time_Counter++;

if ( TimeOut_Counter== Time_Counter ) {Flag_Timeout=1;Time_Counter=0;}

//没收到一个双音频编码会中断一次,处理后送入Dtfm_code寄存器,同时 //置收到双音频编码标志位为1

void DTFMinterrupt1(void) interrupt 2 //riceive a DTFM codec {

Dtfm_code=0x00;

temp=P1; temp1=temp&0x80;

Dtfm_code=Dtfm_code|(temp1>>7); temp1=temp&0x40;

Dtfm_code=Dtfm_code|(temp1>>5); temp1=temp&0x20;

Dtfm_code=Dtfm_code|(temp1>>3); temp1=temp&0x10;

Dtfm_code=Dtfm_code|(temp1>>1);

Flag_Receivecode=1; while(~DTFM_INT); }

//以下为录音子程序 void RecVoice(void) {

P0=0x00; ///----start a 4 second recoder---///////// Time_Counter=0;

TimeOut_Counter=80;//80 equation the 4s REC=0;

while(~Flag_Timeout); Flag_Timeout=0; REC=1;

///----------wait 2 seconds-----//////////// P0=0x20;

Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s while(~Flag_Timeout); Flag_Timeout=0;

///----start a 3 second recoder---///////// Time_Counter=0;

TimeOut_Counter=60;//60 equation the 3s REC=0;

while(~Flag_Timeout);

Flag_Timeout=0; REC=1; ///----------wait 2 seconds-----//////////// P0=0x38;

Time_Counter=0;

}

TimeOut_Counter=40;//40 equation the 2s while(~Flag_Timeout); Flag_Timeout=0;

///----start a 5 second recoder---///////// Time_Counter=0;

TimeOut_Counter=100;//100 equation the 5s REC=0;

while(~Flag_Timeout); Flag_Timeout=0; REC=1;

///----------wait 2 seconds-----//////////// P0=0x66;///start address

Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s while(~Flag_Timeout); Flag_Timeout=0;

///----start a 2 second recoder---///////// Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s REC=0;

while(~Flag_Timeout); Flag_Timeout=0; REC=1;

///----------wait 2 seconds-----//////////// P0=0x76;///start address

Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s while(~Flag_Timeout);

Flag_Timeout=0;

///----start a 2 second recoder---///////// Time_Counter=0;

TimeOut_Counter=40;//40 equation the 2s REC=0;

while(~Flag_Timeout); Flag_Timeout=0; REC=1;


家用电器远程控制 - 图文(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2015年临颍县中考语文模拟试题(三)套

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: