下面是我自己写的一个AD0808的,你可以看看,没有人会给你骗一个现成合你要求的哈。理解,这分可要也可不要。没那么重要为你写上半个小时的程序,理解哈。这是我自己以前学的。希望对你有帮助哈。你看看。。。
#include
#include
#define uchar unsigned char
#define uint unsigned int
void xianshi(uint x);
void yanshi(uint y);
uchar code shuzhu[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit p00=P0^0;
sbit p01=P0^1;
sbit p02=P0^2;
sbit p03=P0^3;
sbit p04=P0^4;
sbit p05=P0^5;
sbit p06=P0^6;
sbit p07=P0^7;
sbit p10=P1^0;
sbit p11=P1^1;
sbit p12=P1^2;
sbit p13=P1^3;
sbit p14=P1^4;
sbit p15=P1^5;
sbit p16=P1^6;
sbit p17=P1^7;
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
sbit p23=P2^3;
sbit p24=P2^4;
sbit p25=P2^5;
sbit p26=P2^6;
sbit p27=P2^7;
sbit p30=P3^0;
sbit p31=P3^1;
sbit p32=P3^2;
sbit p33=P3^3;
sbit p34=P3^4;
sbit p35=P3^5;
sbit p36=P3^6;
sbit p37=P3^7;
uint shu,shu_1;
void main()
{
TMOD=0x01;
TH0=(65535-200)/256;
TL0=(65535-200)%256;
EA=1;ET0=1;TR0=1;
p37=0;
while(1)
{
p37=1;
p37=0;
p13=1;
p10=0;p11=0;p12=0;
while(p15!=0)
{p14=1;
shu=P0;
p14=0;
p37=0;
shu_1=shu*1.0/255*500;
xianshi(shu_1);}
}
}
void yszd() interrupt 1
{
TH0=(65535-200)/256;
TL0=(65535-200)%256;
p36=~p36;
}
void xianshi(uint x)
{
uint g,s,b,q;
g=x%1000%100%10;
P2=shuzhu[g];
p35=0;
yanshi(10);
P2=0;p35=1;
s=x%1000%100/10;
P2=shuzhu[s];
p34=0;
yanshi(10);
P2=0;p34=1;
b=x%1000/100;
P2=shuzhu[b];
p33=0;
yanshi(10);
P2=0;p33=1;
q=x/1000;
P2=shuzhu[q];
p32=0;
yanshi(10);
P2=0;p32=1;
}
void yanshi(uint y)
{
uchar yy;
while(y--)
for(yy=0;yy<110;yy++);
}