第1个回答 2013-10-30
#include<reg51.h>
#define uchar unsigned char
uchar ledtab[]={0x02,0x08,0x20,0x80,0x01,0x40,0x10,0x40}
void delay(uchar a)
{
uchar i,j;
for(i=0;i<a;i++)
for(j=0;j<120;j++);
}
main()
{
uchar i;
while(1)
{
P0=ledtab[i];
delay(100);
i++;
i%=8;
}
}