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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 利用串口輸入整數(shù)簡單代碼

          利用串口輸入整數(shù)簡單代碼

          作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏
          一開始想利用中斷,最終還是利用代碼。



          #include
          #define uchar unsigned char
          #define uint unsigned int
          uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//數(shù)碼表
          uchar num1; //顯示十位
          uchar num0; //顯示個位
          //---------------------------------
          void delay(uint k) //延時
          {
          while(k--);
          }
          //-----------------------------
          void main()
          {
          uchar j;
          TMOD=0x20;
          TH1=0xfd;
          TL1=0xfd;
          TR1=1;
          SCON=0x50;
          while(1)
          {
          while(RI==1)//輸入第一個數(shù)字
          {
          j=SBUF;
          num1=j-0;
          RI=0;
          while(RI==0); // 輸入第二個數(shù)字
          j=SBUF;
          num0=j-0;
          RI=0;
          }
          P0=tab[num1];
          P2=0xfd;
          delay(100);
          P0=tab[num0];
          P2=0xfe;
          delay(100);
          }
          }


          評論


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