基于51单片机的红外遥控编码解码电路

  • 格式:pdf
  • 大小:266.19 KB
  • 文档页数:6

下载文档原格式

  / 6
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

while(1) { while(remotein==1) { _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); remdata++; } if(remdata>m) //高电平>5毫秒退出 {remotedata[n]=0x00;EX0=1;EA=1;goto end;} remotedata[n]=remdata;n++; remdata=0x0000; while(remotein==0) { _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_Biblioteka Baiduop_();_nop_();_nop_();_nop_(); remdata++; } remotedata[n]=remdata; n++; remdata=0x00; } end: lamp=0;studylamp=0; } 电路:
实物:
2009-06-25 12:39
TMOD=0x22; PCON=0X00; TH1=0xf3; TL1=0xf3; IT0=1; EX0=1; EA=1; } //键功能函数 void key_tx() { if(txkey==0) { delay1ms(1); if(txkey==0) { while(txkey==0); ET1=1;TR1=1; for(i=head;i>0;i--); remoteout=0;ET1=0;TR1=0; n=0; while(1) { lamp=0; studylamp=1; if(remotedata[n]==0x00) { delay1ms(10);break; } for(i=remotedata[n];i>0;i--) { _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_(); } n++; ET1=1;TR1=1; for(i=remotedata[n];i>0;i--);
当学习键按下后,红外接收头便可将接受到的信号存储到单片机中。在接受到通用 发出的信号后,如果按下发射键,单片机将调出刚刚储存的信息,通过红外发射头 和遥控器一样的信号来达到控制的作用。 #include <reg52.h> #include <intrins.h> #define uchar unsigned char #define uint unsigned int sbit studylamp=P2^7; sbit lamp=P2^6; sbit studykey=P3^2; sbit remotein=P1^1; sbit remoteout=P1^0; sbit txkey=P2^0; uint i,j,m=255,n,k,s; uchar idata remotedata[206]; uint head; uint remdata; //一毫秒延时程序 delay1ms(uint t) { for(i=0;i<t;i++) for(i=0;j<120;j++); } //初始化函数 clearmen() { studylamp=1; lamp=1; remoteout=0; remotein=1; for(i=0;i<206;i++) { remotedata[i]=0x00; } IE=0x00; IP=0x01;
remoteout=0;ET1=0;TR1=0;n++; } } } } //主函数 void main() { clearmen(); //初始化 while(1) { key_tx(); //按键扫描 } } //40KHz发生器 void time_intt1(void) interrupt 3 { remoteout=~remoteout; } //外中断0 void intt0(void) interrupt 0 { ET1=0;TR1=0;EX0=0;EA=0; head=0; while(studykey==0); studylamp=0;lamp=1; while(remotein==1); head=0; while(remotein==0) { _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); head++; } n=0;remdata=0x0000;