<acronym id="xonnx"></acronym>
      <td id="xonnx"></td>
    1. <pre id="xonnx"></pre>

      1. 專注電子技術學習與研究
        當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

        八通道adc0808數據采集

        作者:佚名   來源:互聯網   點擊數:  更新時間:2014年09月17日   【字體:

        #include<reg52.h>
        #define uint unsigned int
        #define uchar unsigned char
        sbit EN=P0^4;
        sbit EOC=P0^6;
        sbit STA=P0^7;
        sbit ADA=P0^0;
        sbit ADB=P0^1;
        sbit ADC=P0^2;
        sbit ALE=P0^5;
        uchar code tab[11]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xD8,0x80,0x90,0xff};
        uchar code wela[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
        uchar data shu[8]={0,0,0,0,0,0,0,0};
        uint ada=1222,adb=0;
        uchar alley=0;
        void delay(uint z)
        {
        uint x,y;
        for(x=z;x>0;x--)
        for(y=4;y>0;y--);
        }
        void display()
        {

        uchar i,hp;

        for(i=0;i<8;i++)
        {
        if(i==1)hp=0x80;else hp=0;
        P3=wela[i];
        P2=tab[shu[i]]+hp;
        delay(10);
        P3=0X00;
        }
        }
        void disan()
        {
        ada=ada*100/51;
        shu[4]=alley/1000;
        shu[5]=alley%1000/100;
        shu[6]=alley%100/10;
        shu[7]=alley%10;
        shu[0]=ada/1000;
        shu[1]=ada%1000/100;
        shu[2]=ada%100/10;
        shu[3]=ada%10;
        }
        void adc()
        {

        ADA=alley&0x01;
        ADB=alley&0x02;
        ADC=alley&0x04;
        STA=0;
        delay(30);
        STA=1;
        delay(30);
        STA=0;
        while(!EOC)delay(1);
        EN=1;
        delay(2);
        ada=P1;
        EN=0;
        }
        void main()
        {
        uchar a=100;
        while(1)
        {
        a=1000;
        alley++;
        if(alley>7)alley=0;
        adc();
        disan();
        while(a--)
        {

        display();
        }
        }
        }

         

         

         

        關閉窗口

        相關文章

        欧美性色欧美精品视频,99热这里只有精品mp4,日韩高清亚洲日韩精品一区二区,2020国自产拍精品高潮