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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機+74HC595驅(qū)動數(shù)碼管程序

          51單片機+74HC595驅(qū)動數(shù)碼管程序

          作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏
          這里是電路圖:

          完整的源碼和圖紙下載地址:http://www.51hei.com/bbs/dpj-20392-1.html
          下面是51單片機驅(qū)動74hc595芯片的程序:
          #include //包含51單片機的頭文件
          #include
          #define uint unsigned int
          #define uchar unsigned char

          //sbit sin_595 =P1^0;
          //sbit rclk_595 =P1^1;
          //sbit sclk_595 =P1^2;
          //sbit s_clr =P1^3;
          sbit a_cp_595 =P2^4; //串行移位時鐘脈沖 sh_cp_595
          sbit b_cp_595 =P2^3; //輸出鎖存器控制脈沖 st_cp_595
          //sbit _oe_595 =P1^5; //8位并行輸出使能/禁止(高阻態(tài))
          sbit ds_595 =P2^2; //串行數(shù)據(jù)輸入
          extern uchar datas[6]; //存放6個數(shù)碼管的顯示數(shù)字

          uchar ledcode[]={
          0xC0,// 0
          0xF9,// 1
          0xA4,// 2
          0xB0,// 3
          0x99,// 4
          0x92,// 5
          0x82,// 6
          0xF8,// 7
          0x80,// 8
          0x90,// 9
          0x88,// A
          0x83,// B
          0xC6,// C
          0xA1,// D
          0x86,// E
          0x8E// F
          };

          void delay(uint z)
          {
          uint t1,y;
          for(t1=z;t1>0;t1--)
          for(y=110;y>0;y--);
          }
          void led_display(void)
          {
          uchar i,j;
          bit testb;
          uchar bdata movebit[6];
          uchar bdata test;
          //_oe_595=0; //選中數(shù)碼管
          for(i=0;i<6;i++)
          movebit[i]=ledcode[datas[i]];
          // P1=0;
          delay(1);
          for(i=0;i<6;i++) //數(shù)據(jù)移位
          {
          test=movebit[i];
          for(j=0;j<8;j++)
          {
          testb=test&0x80;
          test=test<<1;
          if(testb)
          {
          ds_595=1;
          }
          else
          {
          ds_595=0;
          }
          a_cp_595=1;
          a_cp_595=0;
          } //數(shù)據(jù)移位
          }
          b_cp_595=0;
          b_cp_595=1;
          b_cp_595=0;

          }


          評論


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