标题:
ADC0808数字电压表设计
[打印本页]
作者:
1234567892
时间:
2020-5-25 12:29
标题:
ADC0808数字电压表设计
程序
#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 直流数字电压表设计.rar
2020-5-25 12:29 上传
点击文件名下载附件
下载积分: 黑币 -5
102.06 KB, 下载次数: 26, 下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1