很简单呀,给你一个示范:
#include
#define uchar unsigned char
void delay(uchar a)
{
uchar i,j;
for(i=0;ifor(j=0;j<120;j++);
}
main()
{
uchar LED=0xfe;
while(1)
{
P0=LED;
delay(100);
P0=0xff;
delay(100);
LED=(LED<<1)|0x01;
if(LED==0xff)LED=0xfe;
}
}