代码如下,运用了位运算,仿真图
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delay (uint i)
{
uchar t;
while (i--)
{
for (t=0;t<120;t++);
}
}
void main()
{
int i;
P1=0XFF;//low value
while (1)
{
P1=0XFF;
for(i=0;i<9;i++)
{
P1=P1<<1;
delay(500);
}
}
}