设计一个LED流水灯电路并写出程序.

如题所述

#include<reg51.h>

#define uchar unsigned char

#define uint unsigned int

void Delayms(uint x)

{

uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void main(){

uchar i,j;
while(1)
{

j=0x01; //8个流水灯逐个闪动
for(i=0;i<8;i++)
{
P0=~j;
Delayms(300);
j<<=1;
}
j=0x80; //8个流水灯反向逐个闪动
for(i=0;i<8;i++)
{
P0=~j;
Delayms(300);
j>>=1;
}

}
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2021-01-14

用Arduino制作一个LED流水灯,非常漂亮

第2个回答  2011-07-07
网上有通用的
第3个回答  2011-07-04
JIA WO
相似回答