#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
sbit a1=P2^2;
sbit a2=P2^3;
sbit a3=P2^4;
void delay(uint z)
{
uchar a,b;
for(a=z;a>0;a--)
for(b=110;b>0;b--);
}
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void main()
{
while(1)
{
uint j,i;
for(i=0;i<10;i++)
{
for(j=0;j<8;j++)
{
switch(j)
{
case 0: a1=0;a2=0;a3=0;break;
case 1: a1=1;a2=0;a3=0;break;
case 2: a1=0;a2=1;a3=0;break;
case 3: a1=1;a2=1;a3=0;break;
case 4: a1=0;a2=0;a3=1;break;
case 5: a1=1;a2=0;a3=1;break;
case 6: a1=0;a2=1;a3=1;break;
case 7: a1=1;a2=1;a3=1;break;
}
P0=table[i];
delay(50);
P0=0x00;
}
delay(100);
}
}
}
这个·····在我的数码管上闪得太厉害了~你试下看看,如果你调好了,把程序给我看看