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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 74hc164驅(qū)動(dòng)數(shù)碼管程序

          74hc164驅(qū)動(dòng)數(shù)碼管程序

          作者: 時(shí)間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
          #i nclude

          #define uint unsigned int

          本文引用地址:http://www.ex-cimer.com/article/201611/317066.htm

          #define uchar unsigned char

          sbit DAT=P1^1; //模擬串口數(shù)據(jù)發(fā)送端

          sbit CLK=P1^2;//模擬時(shí)鐘控制端

          uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};//0-9,-,全滅 (共陽字段表)

          void sendbyte(uchar byte)

          {

          uchar num,c;

          num=tab[byte];

          for(c=0;c<8;c++)

          {

          CLK=0;

          DAT=num&0x80; //(0x80即十進(jìn)制的128, 二進(jìn)制的10000000 按位發(fā)送)

          CLK=1;

          num<<=1;

          }

          }

          void delay_50ms(unsigned int t) //50MS演示程序

          {

          unsigned int j;

          for(;t>0;t--)

          for(j=6245;j>0;j--)

          {;}

          }

          main()

          {

          unsigned char h;

          while(1){

          for(h=0;h<10;h++){

          delay_50ms(1);

          sendbyte(h);

          delay_50ms(10);

          }

          h=0;

          }

          }

          下面這段是74ls164 驅(qū)動(dòng)共陰數(shù)碼管的程序源碼

          #i nclude

          #define uint unsigned int

          #define uchar unsigned char

          sbit DAT=P1^1;

          sbit CLK=P1^2;

          uchar code tab[]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xff,0xf6};//0-9,-,全滅

          void sendbyte(uchar byte)

          {

          uchar num,c;

          num=tab[byte];

          for(c=0;c<8;c++)

          {

          CLK=0;

          DAT=num&0x01;

          CLK=1;

          num>>=1;

          }

          }

          void delay_50ms(unsigned int t)

          {

          unsigned int j;

          for(;t>0;t--)

          for(j=6245;j>0;j--)

          {;}

          }

          main()

          {

          unsigned char h;

          while(1){

          for(h=0;h<10;h++){

          delay_50ms(1);

          sendbyte(h);

          delay_50ms(10);

          }

          h=0;

          }

          }



          評(píng)論


          技術(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); })();