void delay(unsigned int n)
{
while(n--)
}
void main()
{
char i
unsigned char led[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}
while(1)
{
for(i=0i<8i++)
{
P1=led[i] //LED接在P1口
delay(10000)
}
for(i=0i<8i++)
{
P1=led[8-i]
delay(10000)
}
}
}
#include <reg51.h>void delay(unsigned int n)
{
while(n--)
}
void main()
{
char i
//可以编好想要怎么流水的灯位的状态
unsigned char led[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}
while(1)
{
for(i=0i<8i++)
{
P1=led[i]//LED接在P1口
delay(10000)
}
for(i=0i<8i++)
{
P1=led[8-i]
delay(10000)
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)