在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > C語言寫的紅外遙控解碼程序

            C語言寫的紅外遙控解碼程序

            作者: 時(shí)間:2012-11-06 來源:網(wǎng)絡(luò) 收藏

            #include "STC89C51RC.H"

            sbit DQ = P4^3;
            sbit SPK = P1^0;


            #include absacc.h>

            #define seg1 XBYTE[0xffec]
            #define seg2 XBYTE[0xffed]
            #define seg3 XBYTE[0xffee]
            #define seg4 XBYTE[0xffef]
            unsigned char IRMcode[4];

            unsigned char code ledmap[]=//共陰LED數(shù)碼管譯碼表
            {
            0x3f,0x06,0x5b,0x4f,0x66,//0,1,2,3,4,
            0x6d,0x7d,0x07,0x7f,0x6f,//5,6,7,8,9,
            0x77,0x7C,0x39,0x5E,0x79,//A,b,C,d,E,
            0x71,//F,
            };

            void delay(unsigned int);

            void main()
            {
            EA = 1;
            EX2 = 1;
            while(1)
            {

            if (IRMcode[2]==~IRMcode[3]){
            seg1 = ~ledmap[IRMcode[2]/100];
            seg2 = ~ledmap[IRMcode[2]/10%10];
            seg3 = ~ledmap[IRMcode[2]%10];
            seg4 = 0xff;//熄滅
            }
            }
            }

            void Sound(void)
            {
            SPK = 0;
            delay(10000);
            SPK = 1;
            }

            void IRMint(void) interrupt 6 using 2
            {
            unsigned char count;
            unsigned int count1;
            unsigned char i,j;
            EA = 0;
            count = 9;
            while(--count)
            {
            delay(100);//440us
            if(DQ){EA = 1;return;}
            }
            while(DQ==0);//通過引導(dǎo)碼余下的低電平
            //以上完成引導(dǎo)碼4.5ms的低電平檢測

            count = 9;
            count1 = 0;
            while(--count)
            {
            delay(100);//440us
            if(DQ==0){EA = 1;return;}
            }
            while(DQ==1)//通過引導(dǎo)碼余下的高電平
            {
            if(count1++>1000) {
            P1=0x55;EA = 1;return;}
            }
            //以上完成引導(dǎo)碼4.5ms的高電平檢測

            count1 = 0;
            for(j=0;j4;j++)//有效字節(jié)數(shù)設(shè)定
            {
            for(i=0;i8;i++)//字節(jié)bit數(shù)
            {
            while(DQ==0);//通過編碼低電平
            delay(200);//延時(shí)判斷編碼高電平維持長度
            IRMcode[j]=1;
            if(DQ)IRMcode[j]|=0x01;
            while(DQ==1){//通過編碼余下的高電平
            if(count1++>2000){EA = 1;return;}
            }
            }
            }

            Sound();
            EA = 1;
            }

            //通用延時(shí)函數(shù)
            //22.1184,10 = 48.4 us (5us+43.4)
            //22.1184,100 = 439 us (43.4*10+5)
            //22.1184,1000 = 4345 us(43.4*100+5)
            //22.1184,10000 = 43450 us(43.45*1000+5)
            void delay(unsigned int t)
            {
            while(--t);
            }

            紅外遙控器相關(guān)文章:紅外遙控器原理

            c語言相關(guān)文章:c語言教程




            關(guān)鍵詞: C語言 紅外遙控 解碼程序

            評(píng)論


            相關(guān)推薦

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

            關(guān)閉