#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit cs=P2^0;
sbit adwr=P3^6;
sbit adrd=P3^7;
sbit intr=P3^0;
code uchar table_dian[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};
code ucahr table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void display(float a)
{
uint qian;
uint bai;
uint shi;
uint ge;
qian=(int)adval_dis/1000;
bai=(int)adval_dis%1000/100;
shi=(int)adval_dis%100/10;
ge=(int)asval_dis%10;
dula=1;
P0=table_dian[qian];
dula=0;
P0=0xff;
wela=1;
P0=0x7e;
wela=0;
delayms(5);
dula=1;
P0=table[bai];
dula=0;
P0=0xff;
wela=1;
P0=0xff;
wela=1;
P0=0x7d;
wela=0;
delayms(5);
dula=1;
P0=table[shi];
dula=0;
P0=0xff;
wela=1;
P0=0x7b;
wela=0;
delayms(5);
dula=1;
P0=table[ge];
dula=0;
P0=0xff;
wela=1;
P0=0x77;
wela=0;
delayms(5);
}
char getxv(uchar v)
{
uchar adv;
cs=0;
adwr=0;
delay(1);
adwr=1;
if(intr==0)
{ cs=0;
adrd=0;
delay(1);
v=P1;
adv=(float)v/256*5.00;
}
return adv;
}
void main()
{
while(1)
{
float t;
t=getxv();
display(t);
}
嗯,是的啊,谢谢
一周热门 更多>