标题:
ADC0809测量模拟电压,用数码管显示,数码管显示不正常,四位数一直闪根本看不清
[打印本页]
作者:
HUANGJIEYO
时间:
2018-3-31 16:54
标题:
ADC0809测量模拟电压,用数码管显示,数码管显示不正常,四位数一直闪根本看不清
ADC0809测量模拟电压,用数码管显示,数码管显示不正常,四位数一直闪根本看不清,也不知道是什么原因。请大家帮我看看
#include< reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_LED[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x7f};
uchar code LED_W[]={0xf7,0xfb,0xfd,0xfe,0xff};
sbit ST=P3^2;
sbit ALE=P3^3;
sbit OE=P3^4 ;
sbit EOC=P3^5 ;
void delayms(uint ms)
{uchar i;
while(ms--)for(i=0;i<120;i++);
}
void display(uchar P)
{ uchar ad_data1,ad_data2,ad_data3,ad_data4;
long ad_0809;
ad_0809=P;
OE=0;
P2=0xff;
ad_data1=(ad_0809*4650/255)/1000;
ad_data2=((ad_0809*4650/255)%1000)/100;
ad_data3=(((ad_0809*4650/255)%1000)%100)/10;
ad_data4=((((ad_0809*4650/255)%1000)%100)%10);
P2=LED_W[3];
P1=DSY_LED[ad_data4];
delayms(3);
P2=LED_W[4];
P2=LED_W[2];
P1=DSY_LED[ad_data3];
delayms(3);
P2=LED_W[4];
P2=LED_W[1];
P1=DSY_LED[ad_data2];
delayms(3);
P2=LED_W[4];
P2=LED_W[0];
P1=DSY_LED[ad_data1]&LED_W[10];
delayms(3);
P2=LED_W[4];
}
void main()
{
while(1)
{
ST=0;ST=1;ST=0;
while(EOC==0);
P2=0xff;
OE=1;
display(P0);
OE=0;
}
}
复制代码
作者:
yzwzfyz
时间:
2018-4-1 16:17
硬件图呢?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1