求大仙,给出“8个LED的闪烁控制,要求亮0.5s,灭0.5s,不断闪烁20次。”的C语言编程程序

2025-03-09 13:22:11
推荐回答(3个)
回答1:

用51单片机?
#include
sbit LED0=P1^0;
sbit LED1=P1^1;
sbit LED2=P1^2;
sbit LED3=P1^3;
sbit LED4=P1^4;
sbit LED5=P1^5;
sbit LED6=P1^6;
sbit LED7=P1^7;
void delay(int x)
{
int y,z;
for(y=x;y>0;y--)
for(z=110;z>0;z--);
}

void mian()
{
char i;
for(i=0;i<20;i++)
{
P1=0xff;
delay(500);
P1=0;
delay(500);
}
}

8个 led 接在P1口

回答2:

8个闪光灯,输入11111111是8个灯亮,00000000时灯灭。
即:FF是灯亮,00是灯灭。

回答3:

用那个板子