求助,如何做到8个LED,流水灯程序,要求第一轮八灯一盏接一盏亮,第二轮两盏接两盏两,这样循环到8盏,而且要循环不灭。求改程序。
#include<reg52.h>
#include<intrins.h>
#define unit unsigned int
#define uchar unsigned char
uchar code w[]={0x00,0x80,0xc0,0xe0,0xf8,0xfc,0xfe};
void delay(unit z)
{
unit x, y;
for(x = 100; x > 0; x--)
for(y = z; y > 0; y--);
}
void main()
{
uchar aa,i,j,e;
i=7;
e=6;
j=i;
while(1)
{
for (j=i;j>0;j--)
{
P1 = w[e];
aa=w[e];
delay(300);
aa= _crol_(aa, 1);
}
i--;
e--;
if(i<=0)
{e=0;
i=8;}
}
}
#include<reg52.h>
#include<intrins.h>
#define unit unsigned int
#define uchar unsigned char
uchar code w[]={0x00,0x80,0xc0,0xe0,0xf8,0xfc,0xfe};
void delay(unit z)
{
unit x, y;
for(x = 100; x > 0; x--)
for(y = z; y > 0; y--);
}
void main()
{
uchar aa,i,j,e;
i=7;
e=6;
j=i;
while(1)
{
for (j=i;j>0;j--)
{
P1 = w[e];
aa=w[e];
delay(300);
aa= _crol_(aa, 1);
}
i--;
e--;
if(i<=0)
{e=0;
i=8;}
}
}