单片机流水灯轮流闪烁代码
时间: 2023-04-03 17:04:39 浏览: 281
单片机流水灯源代码(汇编语言)
5星 · 资源好评率100%
以下是单片机流水灯轮流闪烁代码:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit led1=P1^0;
sbit led2=P1^1;
sbit led3=P1^2;
sbit led4=P1^3;
sbit led5=P1^4;
sbit led6=P1^5;
sbit led7=P1^6;
sbit led8=P1^7;
void delay(uint i)
{
while(i--);
}
void main()
{
while(1)
{
led1=0;
delay(50000);
led1=1;
led2=0;
delay(50000);
led2=1;
led3=0;
delay(50000);
led3=1;
led4=0;
delay(50000);
led4=1;
led5=0;
delay(50000);
led5=1;
led6=0;
delay(50000);
led6=1;
led7=0;
delay(50000);
led7=1;
led8=0;
delay(50000);
led8=1;
}
}
阅读全文