c51单片机LED流水灯
```c++
#include"reg51.h"
typedef unsigned int u16;
typedef unsigned char u8;
unsigned char LSE_CODE[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void delay_10us(u16 ten_us)
{
while(ten_us--);
}
void lsd_z()
{
unsigned char i;
for(i=0;i<8;i++)
{
P2=LSE_CODE[i];
delay_10us(100000);
}
}
void lsd_f()
{
signed char j;
for(j=7;j>=0;j--)
{
P2=LSE_CODE[j];
delay_10us(100000);
}
}
int main()
{
lsd_z();
lsd_f();
return 0;
}
```编程
我尝试加了一条P2=0xff,但是没用
可否让其单单执行这两个for循环一次,也是就是LED灯两次方向相反的逐个点亮后 灭!或者是for循环逐个点亮一次后,灯灭。
主程序结束后,单片机又返回到开始重新运行了。
请参考我的博客,想怎么点灯就怎么点灯,想点多少灯就点多少灯