欢迎来到天天文库
浏览记录
ID:17866532
大小:108.50 KB
页数:7页
时间:2018-09-07
《基于51单片机的红外遥控编码解码的c语言程序和电路》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、更多资料视频下载,学习梦想家园:http://mxroom.com请勿转载!!!作品功能简介:当学习键按下后,红外接收头便可将接受到的信号存储到单片机中。在接受到通用遥控器发出的信号后,如果按下发射键,单片机将调出刚刚储存的信息,通过红外发射头发射出和遥控器一样的信号来达到控制的作用。#include#include#defineucharunsignedchar#defineuintunsignedintsbitstudylamp=P2^7; sbitl
2、amp=P2^6; sbitstudykey=P3^2; sbitremotein=P1^1; sbitremoteout=P1^0; sbittxkey=P2^0; uinti,j,m=255,n,k,s;ucharidataremotedata[206]; uinthead; uintremdata;//一毫秒延时程序d
3、elay1ms(uintt){for(i=0;i4、x01;TMOD=0x22;更多资料视频下载,学习梦想家园:http://mxroom.comPCON=0X00;TH1=0xf3;TL1=0xf3;IT0=1;EX0=1;EA=1;}//键功能函数voidkey_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;5、 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+6、+; ET1=1;TR1=1; for(i=remotedata[n];i>0;i--); remoteout=0;ET1=0;TR1=0;n++; } }}}//主函数更多资料视频下载,学习梦想家园:http://mxroom.comvoidmain(){clearmen(); //初始化while(1){ key_tx(); //按键扫描} }/7、/40KHz发生器 voidtime_intt1(void)interrupt3{remoteout=~remoteout;} //外中断0voidintt0(void)interrupt0{ET1=0;TR1=0;EX0=0;EA=0;head=0;while(studykey==0); studylamp=0;lamp=1;while(remotein==1); head=0; 8、 while(remotein==0){ _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); head++;}n=
4、x01;TMOD=0x22;更多资料视频下载,学习梦想家园:http://mxroom.comPCON=0X00;TH1=0xf3;TL1=0xf3;IT0=1;EX0=1;EA=1;}//键功能函数voidkey_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;
5、 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+
6、+; ET1=1;TR1=1; for(i=remotedata[n];i>0;i--); remoteout=0;ET1=0;TR1=0;n++; } }}}//主函数更多资料视频下载,学习梦想家园:http://mxroom.comvoidmain(){clearmen(); //初始化while(1){ key_tx(); //按键扫描} }/
7、/40KHz发生器 voidtime_intt1(void)interrupt3{remoteout=~remoteout;} //外中断0voidintt0(void)interrupt0{ET1=0;TR1=0;EX0=0;EA=0;head=0;while(studykey==0); studylamp=0;lamp=1;while(remotein==1); head=0;
8、 while(remotein==0){ _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_(); head++;}n=
此文档下载收益归作者所有