#include"reg51.h"
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^0;
sbit dula=P2^1;
sbit adcs=P2^2;
sbit adrd=P2^3;
sbit adwr=P2^4;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71
};
void init()
{
EA=1;
EX0=1;
}
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--) ;
}
void display(uchar bai,uchar shi,uchar ge)
{
dula=1;
P1=table[bai];
dula=0;
P1=0xff;
wela=1;
P1=0xfe;
wela=0;
delayms(50);
dula=1;
P1=table[shi];
dula=0;
P1=0xff;
wela=1;
P1=0xfd;
wela=0;
delayms(50);
dula=1;
P1=table[ge];
dula=0;
P1=0xff;
wela=1;
P1=0xfb;
wela=0;
delayms(50);
}
void main()
{
init();
uchar aa,aa1,aa2,aa3,adval;
aa1=aa2=aa3=0;
adcs=0;
while(1)
{
adwr=1;
_nop_();
adwr=0;
_nop_();
adwr=1;
for(aa=10;aa>0;aa--)
{
display(aa1,aa2,aa3);
}
aa1=adval/100;
aa2=adval%100/10;
aa3=adval%10;
}
}
void int0() interrupt 0
{
P0=0xff;
adrd=1;
_nop_();
adrd=0;
_nop_();
adval=P0;
adrd=1;
}
回答正确多多加分哦。