自己做一个电压表,有点问题求请教!
图
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit START=P1^0;
sbit EOC=P1^1;
sbit OE=P1^2;
sbit ADDA=P1^3;
sbit ADDB=P1^4;
sbit ADDC=P1^5;
sbit dula=P1^6;
sbit wela=P1^7;
float temp;
uchar num,ge,shi,bai;
void delay(uint z)
{
uint x;
uchar y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void ad0809()
{
START=0;
START=1;
START=0;
while(!EOC);
OE=1;
temp=P2;
num=((500*temp)/255);
delay(1);
OE=0;
ge=num%100;
shi=num/10%10;
bai=num/100;
}
void main()
{
ADDA=0;
ADDB=0;
ADDC=0;
while(1)
{
ad0809();
wela=1;
P0=0xfd;
wela=0;
dula=1;
P0=table[bai]|0x80;
dula=0;
delay(5);
wela=1;
P0=0xfb;
wela=0;
dula=1;
P0=table[shi];
dula=0;
delay(5);
wela=1;
P0=0xf7;
wela=0;
dula=1;
P0=table[ge];
dula=0;
delay(5);
}
}
求大神指点。
说你的问题啊
就是这个程序写的有问题,测出的值是错的。