这个简单
没有格子 你就从上往下看吧 那看不明白 问我吧
# include
unsigned char code tab[]={0xc0, 0xf9, 0xa4, 0xb0,
0x99, 0x92, 0x82, 0xf8,
0x80, 0x90, 0x88, 0x83,
0xc6, 0xa1, 0x86, 0x8e,};
sbit aj1 = P1^0;
void delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
P0 = 0xff;
while(1)
{
if(aj1==0)
{
delay(5);
if(aj1==0)
{
P0= tab[1];
while(!aj1);
}
}
if(aj1==0)
{
delay(5);
if(aj1==0)
{
P0= tab[0];
while(!aj1);
}
}
}
}
流水灯程序
# include
void delay500ms(void) //时间500MS
{
unsigned char a,b,c;
for(c=98;c>0;c--)
for(b=127;b>0;b--)
for(a=17;a>0;a--);
}
void main()
{
unsigned char i,k;
while(1)
{
i=0xfe;
for(k=0;k<8;k++)
{
P1=i;
delay500ms();
i=(i<<1)|0x01;
}
}
}
当然还有别的写法