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

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

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

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

      2. 新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)+MAX7219數(shù)碼管顯示C程序

        51單片機(jī)+MAX7219數(shù)碼管顯示C程序

        作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
        /**************************************************

        *程序名稱(chēng): MAX7219 C語(yǔ)言控制程序
        *程序功能: 3線(xiàn)串行控制8位共陰數(shù)碼管
        *3線(xiàn)定義:DIN 串行數(shù)據(jù)輸入
        * LOAD 數(shù)據(jù)鎖存
        * CLK 時(shí)鐘輸入
        ***************************************************/
        #include
        #include
        sbit pinDIN=P0^0; //串行數(shù)據(jù)輸入端
        sbit pinLOAD=P0^1; //數(shù)據(jù)鎖存端
        sbit pinCLK=P0^2; //時(shí)鐘輸入端
        #define uchar unsigned char
        uchar code LEDcode[]=
        {0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x7b,0x00 /*0,1,2,3,4,5,6,7,8,9,全滅*/
        /* 0x77,0x1f,0x4e,0x3d,0x4f,0x47,0x67,0x3e,0xff, */ }; /*A,B,C,D,E,F,P,U,全亮*/

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

        /**************************************************
        * 向MAX7219寫(xiě)入字節(jié)(8位)函數(shù) *
        ***************************************************/
        void sendbyte (uchar dat)
        {
        uchar i,temp;
        _nop_();
        for (i=0;i<8;i++)
        {
        temp=dat&0x80;
        dat=dat<<1;
        if(temp)
        pinDIN=1;
        else
        pinDIN=0;
        pinCLK=0;
        _nop_();
        pinCLK=1;
        }
        }
        /**************************************************
        * 向MAX7219寫(xiě)入地址和控制字(16位) *
        ***************************************************/
        void sendword (uchar addr,uchar dat)
        {
        pinLOAD=0;
        _nop_();
        sendbyte (addr);
        _nop_();
        sendbyte (dat);
        _nop_();
        pinLOAD=1; //第16個(gè)上升沿之后,第17個(gè)上升沿之前必須把pinCLK置高,否則數(shù)據(jù)丟失
        }
        /**************************************************
        * MAX7219初始化 *
        ***************************************************/
        void init7219 (void)
        {
        sendword (0x0c,0x01); /* 設(shè)置電源工作模式 */
        sendword (0x0a,0x09); /* 設(shè)置亮度 19/32 */
        sendword (0x0b,0x03); /* 設(shè)置掃描界限 */
        sendword (0x09,0x00); /* 設(shè)置譯碼模式 */
        sendword (0x0f,0x00); /*顯示測(cè)試 00為正常工作狀態(tài)*/
        }
        /**************************************************
        * MAX7219清除顯示 *
        ***************************************************/
        void clear7219(void)
        {
        uchar i;
        for(i=8;i>0;i--)
        {
        sendword(i,0x00);
        }
        }
        /**************************************************
        * MAX7219主函數(shù) *
        ***************************************************/
        /*void main(void)
        {
        init7219 ();
        //clear7219();
        while(1)
        {
        clear7219();
        sendword(0x01,LEDcode[11]);
        sendword(0x02,LEDcode[12]|0x80);
        sendword(0x03,LEDcode[13]);
        sendword(0x04,LEDcode[4]);
        sendword(0x05,LEDcode[5]);
        sendword(0x06,LEDcode[6]);
        sendword(0x07,LEDcode[7]);
        sendword(0x08,LEDcode[8]);

        }
        }*/



        評(píng)論


        技術(shù)專(zhuān)區(qū)

        關(guān)閉