谢谢
Q4:仿照交通灯的例子,再写一道流水灯的题。要求:至少使用8个LED灯,最好是不同颜色的。而且要在一定时间间隔内,按照不通的频率闪烁LED灯。
A4:
const unsigned char led_array[8] = {0, 1,2,3 ,4 ,5 ,6,7};
void setup()
{
unsigned char i;
for(i = 0; i < 8; i++)
{
pinMode(led_array[i], OUTPUT);
}
}
void loop()
{
unsigned char i;
for(i = 0; i < 8; i++)
{
digitalWrite(led_array[i], HIGH);
delay(200 + 20 * i);
digitalWrite(led_array[i], LOW);
delay(200 + 20 * i);
}
}


我要赚赏金
