单片机流水灯程序 功能是led1到led8依次点亮 再从led8亮到led1 但这个程序只会亮一边 求解
问题描述:
#include<reg52.h>
#define uc unsigned char
#define ut unsigned int
#include<intrins.h>
void Delay100ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void main()
{
while(1)
{
ut x;
ut a;
a=0x7f;
x=8;
while(x)
{
P1=a;
a=_crol_(a,1);
Delay100ms();
x--;
}
a=0xef;
x=8;
while(8-x)
{
P1=a;
a=_cror_(a,1);
Delay100ms();
x++;
}
}
}
答
41行改成
x=0;
答
第41行
x=0;
这样应该可以两个方向顺次亮