经过几天的不眠不休,结合我们老师是方法和网络资料,加上自己不断的学习,思考,修改,终于成功的让数码管动态显示出来,并且能从0~99自动跳转。接下来继续努力,把程序再简化。耶,又成功了一步,辛苦的付出总能见到美好的收获。加油加油!
#include"reg51.h"
#define uchar unsigned char
#define uint unsigned int
uchar code smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar data yy[2]={0,0};
uint a;
sbit P30=P3^0;
sbit P31=P3^1;
void delayms(uint m)
{
uchar i,j;
for(i=m;i>0;i--)
for(j=110;j>0;j--);
}
void calc()
{
P30=1;
P2=smg[yy[6]];
delayms(10);
P3=0;
P31=1;
P2=smg[yy[7]];
delayms(10);
P3=0;
}
void JS()
{
a++;
if(a==10) a=0;
yy[7]=a%10; //个位
yy[6]=a/10; //十位
}
void main()
{
uint i;
while(1)
{
for(i=250;i>0;i--)
{
calc();
}
JS();
}
}

