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

<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ī)的各種花樣的流水燈c51程序

        基于51單片機(jī)的各種花樣的流水燈c51程序

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

        /*-----------------------------------------------
        功能:燈對稱移動閃爍(雙閃爍)

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

        ------------------------------------------------*/

        #includeREG52.H>
        #define uint unsigned int
        void delay(uint);
        main()
        {
        uint comp1=0xfe;
        uint comp2=0x80;
        P1=0x7e;
        delay(30000);
        while(1)
        {
        P1=0xff;
        comp1=1;
        comp1|=0x01;
        comp2>>=1;
        P1=comp1;
        P1^=comp2;
        delay(30000);
        if(P1==0xe7)
        {
        comp1=1;
        comp1|=0x01;
        comp2>>=1;
        }

        if(comp1==0x7f)
        {
        comp1=0xfe;
        comp2=0x80;
        }
        }
        }
        void delay(uint cnt)
        {
        while(cnt--);
        }


        /*-----------------------------------------------------------------

        只循環(huán)一次,而沒有一直循環(huán)下去,出錯地方在:

        通過添加一條測試語句:

        if(comp1==0x7f)
        {
        comp1=0xfe; comp2=0x80;
        P1=0x00; delay(30000);

        }

        發(fā)現(xiàn)if語句沒有被執(zhí)行,自然繼續(xù)左右移動:

        1111 11111111 1111^0000 0000==11111 1111

        所以看起來是執(zhí)行了一次while中的代碼。

        具體為什么不行,還不清楚……

        更正下列代碼后,能夠?qū)崿F(xiàn)功能。

        if(P1==0x7e)
        {
        comp1=0xfe;
        comp2=0x80;
        }

        或者:

        if(comp2==0x01)
        {
        comp1=0xfe;
        comp2=0x80;
        }

        --------------------------------------------------------------*/


        上一頁 1 2 3 下一頁

        評論


        相關(guān)推薦

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

        關(guān)閉