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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 51單片機電子時鐘程序

          51單片機電子時鐘程序

          作者: 時間:2016-12-01 來源:網絡 收藏

          unsigned char busy(void)//判忙函數
          {
          bit result;
          RS=0;
          RW=1;
          E=1;
          _nop_();
          _nop_();
          _nop_();
          _nop_();
          result=BF;
          E=0;
          return result;
          }
          void writeinstruction(uchar dictate)//寫指令
          {
          while(busy()==1);
          RS=0;
          RW=0;
          E=0;
          _nop_();
          _nop_();
          P0=dictate;
          _nop_();
          _nop_();
          _nop_();
          _nop_();
          E=1;
          _nop_();
          _nop_();
          _nop_();
          _nop_();
          E=0;
          }
          void writeaddress(uchar x)//寫地址
          {
          writeinstruction(x|0x80);
          }
          void wretedata(uchar y)//寫數據
          {
          while(busy()==1);
          RS=1;
          RW=0;
          E=0;
          P0=y;
          _nop_();
          _nop_();
          _nop_();
          _nop_();
          E=1;
          _nop_();
          _nop_();
          _nop_();
          _nop_();
          E=0;
          }
          void init(void)//初始化
          {
          d=0;
          delay(15);
          writeinstruction(0x38);//工作方式:8位總線,2行,5*7點陣
          delay(5);
          writeinstruction(0x38);//工作方式:8位總線,2行,5*7點陣
          delay(5);
          writeinstruction(0x38);//工作方式:8位總線,2行,5*7點陣
          delay(5);
          writeinstruction(0x0f);//顯示狀態(tài):顯示開,有光標,光標閃爍
          delay(5);
          writeinstruction(0x06);//光標移動:光標右移,字符不移
          delay(5);
          writeinstruction(0x01);
          delay(5);
          }
          void main(void)
          {
          unsigned char D1,D2,D3,D4,D5; //定義變量i指向字符串數組元素
          unsigned int x; //定義變量,儲存檢測結果
          unsigned char i;
          init();
          delay(10);
          writeaddress(0x02);
          i=0;
          while(string[i]!=0)
          {
          wretedata(string[i]);
          i++;
          }
          while(1)
          {
          x=rand();
          D1=x%10;
          D2=x%10000%1000%100/10;
          D3=x%10000%1000/100;
          D4=x%10000/1000;
          D5=x/10000;
          writeaddress(0x45);
          wretedata(digit[D5]);
          wretedata(digit[D4]);
          wretedata(digit[D3]);
          wretedata(digit[D2]);
          wretedata(.);
          wretedata(digit[D1]);
          for(i=0;i<4;i++)
          delay(250);
          }
          }


          上一頁 1 2 下一頁

          關鍵詞: 51單片機電子時

          評論


          技術專區(qū)

          關閉
          看屁屁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); })();