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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機學習——LED顯示實驗之二

          單片機學習——LED顯示實驗之二

          作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          題目:在八位LED顯示屏,顯示“HELLO”:1、使“HELLO”字樣閃爍 2、使字樣“HELLO”從左至右滾動顯示。并且循環(huán)下去。

          解決方案:(C語言編程)

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

          #include
          #include
          #define uint unsigned int
          #define uchar unsigned char
          uchar hello_table[]={0x89,0x86,0xc7,0xc7,0xc0,0xff};
          uchar sled_bit_table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
          uchar sled_disp_buff[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x89,0x86,0xc7,0xc7,0xc0,
          0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
          #define sled_dm_port P0
          #define sled_wm_port P2
          sbit speaker_en_port = P3^7;
          sbit le=P3^6;
          sbit led_en_port=P2^5;
          void display(uchar aa,uchar bb,uchar cc,uchar dd,uchar ee,uchar ba,uchar sh,uchar g);
          void delay(uint a) {
          uint i,j;
          for(j=a;j>0;j--)
          for(i=220;i>0;i--);
          }
          void main()
          {
          uchar i,j,k,a,b,c,d;
          uint count=4;
          led_en_port=0;
          speaker_en_port = 0;
          while(1){
          c=5;
          while(c){
          for(a=0;a<50;a++)
          display(5,0,1,2,3,4,5,5);
          for(b=0;b<50;b++)
          display(5,5,5,5,5,5,5,5);
          c--;
          }
          le=1;
          k=16;
          while(k) {
          for(j=0;j<50;j++){
          for(i=0;i<8;i++){
          sled_wm_port = 0xff;
          sled_dm_port = sled_disp_buff[i+count];
          sled_wm_port = sled_bit_table[i];
          delay(1);
          }
          }
          count++;
          if(count>=8)
          count=4;
          k--;
          }
          d=5;
          while(d){
          for(a=0;a<50;a++)
          display(5,0,1,2,3,4,5,5);
          for(b=0;b<50;b++)
          display(5,5,5,5,5,5,5,5);
          d--;
          }
          }
          }
          void display(uchar aa,uchar bb,uchar cc,uchar dd,uchar ee,uchar ff,uchar hh,uchar ii)
          {
          le=1;
          P2=sled_bit_table[0];
          le=0;
          le=1;
          P0=hello_table[aa];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[1];
          le=0;
          le=1;
          P0=hello_table[bb];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[2];
          le=0;
          le=1;
          P0=hello_table[cc];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[3];
          le=0;
          le=1;
          P0=hello_table[dd];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[4];
          le=0;
          le=1;
          P0=hello_table[ee];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[5];
          le=0;
          le=1;
          P0=hello_table[ff];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[6];
          le=0;
          le=1;
          P0=hello_table[hh];
          le=0;
          delay(1);
          le=1;
          P2=sled_bit_table[7];
          le=0;
          le=1;
          P0=hello_table[ii];
          le=0;
          delay(1);
          }



          關(guān)鍵詞: 單片機LED顯示實

          評論


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