標(biāo)題: ADC0808數(shù)字電壓表設(shè)計(jì) [打印本頁]

作者: 1234567892    時(shí)間: 2020-5-25 12:29
標(biāo)題: ADC0808數(shù)字電壓表設(shè)計(jì)
程序
#include<reg51.h>
//#include "LM016L.h"

sbit CLK=P2^4;
sbit ST=P2^5;
sbit EOC=P2^6;
sbit OE=P2^7;
sbit BUZZ=P3^1;
float d;

#define uint unsigned int
#define  uchar unsigned char
uchar code DSY_CODE[]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
uchar code DSY_CODE1[]={0xbf, 0x8f, 0xdb, 0xcf, 0xe6, 0xed, 0xfd, 0x87, 0xef, 0xdf};

void DelayMs(uint ms)
{
      uchar i;
      while(ms--)
          for(i=0;i<120;i++);
}


void Disp_result(d)
{
        d=(d/255.000)*5000;
       
        P2=0xfe;
        P0=DSY_CODE1[d/1000];
        DelayMs(5);
       
         P2=0xfd;
        P0=DSY_CODE[(d/100)%10];
        DelayMs(5);
       
    P2=0xfb;
        P0=DSY_CODE[(d/10)%10];
        DelayMs(5);
       
    P2=0xf7;
        P0=DSY_CODE[(d)%10];
        DelayMs(5);
       
        if(d>3210)
        {BUZZ=0;
        }
        else{BUZZ=1;
        }
}

void  Timer0_INT() interrupt 1
{
        CLK=~CLK;
}



void main()
{

               
  TMOD=0x02;
        TH0=0x14;
        TL0=0x00;
        IE=0x82;
        TR0=1;
        P3=0x3f;
        BUZZ=1;

        while(1)
        {
                ST=0;ST=1;ST=0;
                while(EOC==0);
                OE=1;
                Disp_result(P1);
                OE=0;
        }
}


ADC0808 直流數(shù)字電壓表設(shè)計(jì).rar

102.06 KB, 下載次數(shù): 26, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1