<acronym id="xonnx"></acronym>
      <td id="xonnx"></td>
    1. <pre id="xonnx"></pre>

      1. 專注電子技術學習與研究
        當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

        實現LED點陣左右移動的程序

        作者:佚名   來源:不詳   點擊數:  更新時間:2014年08月17日   【字體:

         

         
         
        #include<reg52.h>
        #define uchar unsigned char
        unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//定義掃描列
        unsigned char code digittab[]={
         
        0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00, //0
         
        0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00, //1
         
        0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //2
         
        0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00, //3
         
        0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00, //4
         
        0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00, //5
         
        0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00, //6
         
        0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00, //7
         
        0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00, //8
         
        0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00, //9
         
        0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00, //P
         
        0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00, //R
         
        0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00, //E
         
        0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00, //C
         
        0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00, //H
         
        0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00, //I
         
        0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00, //N
         
        0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //中
         
        };//要顯示的字符
         
        void delay(int t)
        {
         int i;
         for(i=1;i<=t;i++);
        }//延時函數
        void main(void)
        {
         int a,b,c;
         while(1)
         {
          for(a=0;a<144;a++)  //所有要顯示的列數
          {
           
            for(b=0;b<50;b++)//控制移動速度
            {
            P2=0xfe;      ///最右邊的列先顯示,程序定義向左移動
            for(c=0;c<8;c++)//稍加修改可以變成向右移動
            {                //例中P2接LED點陣陽極,P0接陰極
             P0=digittab[a+c];//同時顯示8列
             delay(100);
             P0=0x00;   //禁止掃描列變換時,其它列亮!
             P2=P2<<1|P2>>7;
            
             }
             }
            
          }
         
        注:對本程序稍加修改可以變成LED8段數碼管左右移動程序。
         
        關閉窗口
        欧美性色欧美精品视频,99热这里只有精品mp4,日韩高清亚洲日韩精品一区二区,2020国自产拍精品高潮