<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 數(shù)碼管動態(tài)掃描三種實現(xiàn)方法

          數(shù)碼管動態(tài)掃描三種實現(xiàn)方法

          作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
          本程序所用的原理圖下載:點這里,單片機芯片使用的stc89c51;找到數(shù)碼管部分的原理圖即可.這是一整個單片機開發(fā)板的電路圖其他的忽略.

          以下是3個程序的源碼:
          /**********利用定時器定時50毫秒動態(tài)掃描數(shù)碼管***********/
          /**
          *功能:定時器T1實現(xiàn)數(shù)碼管動態(tài)掃瞄123456(if)
          *作者:徐冉
          *日期:2013-06-12-22:10
          *備注:不同的方法實現(xiàn)顯示設(shè)備的動態(tài)掃描,節(jié)約能耗
          **/
          /****************AT89C52-RC MCU*************/
          /****************51hei開發(fā)板*************/
          #include
          typedef unsigned int uint;
          typedef unsigned char uchar;
          sbit wela = P2^7;
          sbit dula = P2^6;
          //段選數(shù)據(jù)編碼表
          uchar code table[] = {
          0x3F, //"0"
          0x06, //"1"
          0x5B, //"2"
          0x4F, //"3"
          0x66, //"4"
          0x6D, //"5"
          0x7D, //"6"
          0x07, //"7"
          0x7F, //"8"
          0x6F //"9"
          };
          //位選數(shù)據(jù)編碼表
          uchar code table1[] = {
          0xfe,
          0xfd,
          0xfb,
          0xf7,
          0xef,
          0xdf
          };
          uchar j = 1, counter = 0;
          //延時程序
          void display()
          {
          dula = 1;
          P0 = table[j++];
          dula = 0;
          if(j >= 7)
          {
          j = 1;
          }
          }
          //刷新程序
          void refrash()
          {
          static uchar i = 0;
          if(0 == i)
          {
          wela = 1;
          P0 = table1[0];
          wela = 0;
          }
          if(1 == i)
          {
          wela = 1;
          P0 = table1[1];
          wela = 0;
          }
          if(2 == i)
          {
          wela = 1;
          P0 = table1[2];
          wela = 0;
          }
          if(3 == i)
          {
          wela = 1;
          P0 = table1[3];
          wela = 0;
          }
          if(4 == i)
          {
          wela = 1;
          P0 = table1[4];
          wela = 0;
          }
          if(5 == i)
          {
          wela = 1;
          P0 = table1[5];
          wela = 0;
          }
          i++;
          if(i >= 6)
          {
          i = 0;
          }
          }
          //定時器T1初始化
          void init()
          {
          P0 = 0x00;//關(guān)閉數(shù)碼管顯示
          TMOD = 0x11;
          TH1 = 0xFC; //T1定時1毫秒
          TL1 = 0x66;
          TR1 = 1;
          EA = 1;
          ET1 = 1;
          }
          //主程序
          void main(void)
          {
          init();
          while(1)
          {
          if(counter == 50)
          {
          counter = 0;
          display();//顯示
          refrash();//刷新
          }
          }
          }
          //T1中斷服務(wù)程序
          void timer1_int() interrupt 3
          {
          TH1 = 0xFC;
          TL1 = 0x66;
          counter++;
          }


          上一頁 1 2 下一頁

          評論


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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();