呼吸灯89c52代码
时间: 2023-10-31 15:07:22 浏览: 47
呼吸灯代码
以下是89c52单片机实现呼吸灯的代码:
```c
#include <reg52.h>
sbit LED = P1^0; // 呼吸灯连接的IO口
void Delay(unsigned int xms) {
unsigned char i, j;
while(xms--) {
i = 2;
j = 239;
do {
while (--j);
} while (--i);
}
}
void main() {
while(1) {
for (int i = 0; i <= 255; i++) {
LED = i;
Delay(5);
}
for (int i = 255; i >= 0; i--) {
LED = i;
Delay(5);
}
}
}
```
阅读全文