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

          新聞中心

          51單片機(jī)-蜂鳴器

          作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏


          單片機(jī)如何輸出頻率:



          得到600HZ的頻率:

          #include
          sbit p = P3^4;

          void main(){
          p = 1;
          EA = 1;
          ET0 = 1;
          TMOD = 0x01;
          TH0 = (65536-833)/256;
          TL0 = (65536-833)%256;
          TR0 = 1;
          while(1);
          }

          void time0() interrupt 1{
          p = ~p;
          TH0 = (65536-833)/256;
          TL0 = (65536-833)%256;
          }

          內(nèi)循環(huán)一次8.3us

          void delay8us(unsigned char x){
          unsigned char i,j;
          for(i = 0; i < x; i++)
          for(j = 0; j < 1; j++)
          ;
          }

          音符頻率及定時器初值對照表:




          4*4電子琴程序的實現(xiàn):

          #include
          #define uchar unsigned char
          #define uint unsigned int
          uint DATE,i;
          sbit buzz = P3^4;
          sbit L0 = P0^0;
          sbit L1 = P0^1;
          sbit L2 = P0^2;
          sbit L3 = P0^3;
          sbit H0 = P0^4;
          sbit H1 = P0^5;
          sbit H2 = P0^6;
          sbit H3 = P0^7;
          uchar TH0_DATA = 0;
          uchar TL0_DATA = 0;
          uchar code qin[] = {262,277,293,329,349,392,440,494};


          評論


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