在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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>

            新聞中心

            按鍵控制LED

            作者: 時間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
            #include
            #define unchar unsigned char
            sbit k1=P3^0;
            sbit k2=P3^1;
            sbit k3=P3^2;
            sbit k4=P3^3;
            sbit k5=P3^4;
            sbit k6=P3^5;
            sbit k7=P3^6;
            sbit k8=P3^7;//按鍵號碼
            unchar spyon();
            unchar led,a,b;
            static unchar flag=0;
            void zhma();
            voidfanma();
            voidzheshui();
            voidfanshu();
            voidquanm();
            void quanliang();
            void delay();
            void main()
            {
            while(1)
            {
            P3=0xff;
            if(flag==0)
            {
            P2=0;
            delay();
            P2=0xff;
            delay();
            }
            flag=spyon();
            switch(flag)
            {
            case 1://D2,D7滅
            {
            zhma();
            break;
            }
            case 2://D3,D7亮
            {
            fanma();
            break;
            }
            case 3://D3,D7滅
            {
            zheshui();
            break;
            }
            case 4://一號燈閃亮
            {
            fanshu();
            break;
            }
            case 5://閃亮
            {
            quanm();
            break;
            }
            case 6://全亮
            {
            quanliang();
            break;
            }
            case 7://亮后4個燈
            {
            led=0xf0;
            P2=led;
            break;
            }
            case 8://亮前四個燈
            {
            led=0x0f;
            P2=led;
            break;
            }
            default:
            {

            break;
            }
            }
            }
            }
            unchar spyon()
            {
            a=P3;
            a=a&0xf0;
            if(a!=0xf0)
            {
            a=~((a>>4)|0xf0);
            if(a==1)
            return 5;
            else if(a==2)
            return 6;
            else if(a==4)
            return 7;
            else if(a==8)
            return 8;
            }
            else
            {
            a=P3;
            a=a&0x0f;
            if(a!=0x0f)
            {
            a=~(a|0xf0);
            if(a==1)
            return 1;
            else if(a==2)
            return 2;
            else if(a==4)
            return 3;
            else if(a==8)
            return 4;
            }
            }
            }
            void zhma()
            {
            unchar led;
            led=0x42;
            P2=led;
            delay();
            }
            voidfanma()
            {
            unchar led;
            led=0xdd;
            P2=led;
            delay();
            }
            voidzheshui()
            {
            unchar led;
            led=0x22;
            P2=led;
            delay();
            led=0xfe;

            }
            voidfanshu()
            {
            led=0xff;
            P2=led;
            delay();
            led=0x7f;
            P2=led;
            delay();
            }
            voidquanm()
            {
            led=0x7e;
            P2=led;
            delay();
            led=0xdd;
            P2=led;
            delay();
            }
            void quanliang()
            {
            P2=0;
            }
            void delay()
            {
            for(a=0;a<200;a++)
            for(b=0;b<200;b++);
            }


            關(guān)鍵詞: 按鍵控制LE

            評論


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

            關(guān)閉