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

          新聞中心

          AT89s51-ADC0804實驗

          作者: 時間:2012-08-18 來源:網(wǎng)絡(luò) 收藏

          點擊瀏覽下一頁


          /*****************************************,AT89S51連接:數(shù)碼管:P0數(shù)據(jù),段選P2^7,位選P2^6.:數(shù)據(jù)輸出P1WR=P3^6RD=P3^7INTR懸空CS接GND 現(xiàn)象:擰動 數(shù)碼管示數(shù)在0--255之間*****************************************/#include reg51.h>   #include intrins.h>sbit duanxuan=P2^7;sbit weixuan=P2^6; sbit AD_WR=P3^6;  //定義的WR端口sbit AD_RD=P3^7;  //定義ADC0804的RD端口unsigned char shu[8];unsigned char code duanma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};unsigned char code weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};/****************************************延時函數(shù)****************************************/void delayms(unsigned int xms)    {unsigned char i,j;for(i=xms;i>0;i--) for(j=120;j>0;j--);}/****************************************顯示函數(shù)****************************************/void display(){unsigned char i;for(i=0;i3;i++){P0=0;duanxuan=1;duanxuan=0;P0=weima[i];weixuan=1;weixuan=0;P0=shu[i];duanxuan=1;duanxuan=0;delayms(4);} }/****************************************MAIN****************************************/void main() {unsigned char adval;unsigned int a ;while(1){AD_WR=1;_nop_();AD_WR=0;//啟動AD轉(zhuǎn)換_nop_();AD_WR=1;for(a=10;a>0;a--)  //啟動轉(zhuǎn)換后要多留點時間用來轉(zhuǎn)換{ display();}P1=0xff;  //讀取P1口之前先給其寫全1 AD_RD=1;  _nop_(); AD_RD=0;//AD讀使能_nop_();adval=P1;  //AD數(shù)據(jù)讀取賦給advalAD_RD=1;shu[0]=duanma[adval/100];shu[1]=duanma[adval%100/10];shu[2]=duanma[adval%10];display();for(a=100;a>0;a--)display();}}


          關(guān)鍵詞: AT89s51 ADC0804 滑動變阻器

          評論


          相關(guān)推薦

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