中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于51單片機(jī)紅外編碼解碼的C語言程序

        基于51單片機(jī)紅外編碼解碼的C語言程序

        作者: 時(shí)間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
        當(dāng)學(xué)習(xí)鍵按下后,紅外接收頭便可將接受到的信號(hào)存儲(chǔ)到單片機(jī)中。在接受到通用遙控器發(fā)出的信號(hào)后,如果按下發(fā)射鍵,單片機(jī)將調(diào)出剛剛儲(chǔ)存的信息,通過紅外發(fā)射頭發(fā)射出和遙控器一樣的信號(hào)來達(dá)到控制的作用。

        #include
        #include
        #define uchar unsigned char
        #define uint unsigned int

        本文引用地址:http://www.antipu.com.cn/article/201611/320393.htm

        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;


        //一毫秒延時(shí)程序
        delay1ms(uint t)
        {
        for(i=0;i for(i=0;j<120;j++);
        }

        //初始化函數(shù)
        clearmen()
        {
        studylamp=1;
        lamp=1;
        remoteout=0;
        remotein=1;
        for(i=0;i<206;i++)
        {
        remotedata[i]=0x00;
        }
        IE=0x00;
        IP=0x01;
        TMOD=0x22;
        PCON=0X00;
        TH1=0xf3;
        TL1=0xf3;
        IT0=1;
        EX0=1;
        EA=1;
        }

        //鍵功能函數(shù)
        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--);
        remoteout=0;ET1=0;TR1=0;n++;
        }
        }
        }
        }

        //主函數(shù)
        void main()
        {
        clearmen(); //初始化
        while(1)
        {
        key_tx(); //按鍵掃描
        }
        }

        //40KHz發(fā)生器
        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;
        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_();_nop_();_nop_();_nop_();_nop_();
        remdata++;
        }
        remotedata[n]=remdata;
        n++;
        remdata=0x00;
        }
        end: lamp=0;studylamp=0;
        }



        評(píng)論


        技術(shù)專區(qū)

        關(guān)閉