用单片机设计8个led灯同时闪烁的程序!!

如题所述

方法:
1:设定一个变量i,可以从0到3循环的变化
2:检测一个经过消抖处理的按键,按一下,i+1
3:当i值为各个值时,执行相应的花样。

流水灯参考程序
#include
#include
#define uchar unsigned char
uchar j,temp;
void delay(unsigned int ms)
{
uchar t;
while(ms--)
for(t=0;t<123;t++);
}
void main()
{
P1=0xff;
delay(500);
temp=0xfe; //有点怪,led接在P2.3~P2.6
for(j=0;j<4;j++)
{
P1=temp;
delay(500);
temp=_crol_(temp,1);
}
P1=0xff;
while(1);
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答