arduino嵌入式设计实验例程源代码-六个LED灯流水灯设计
/設定數字I/O腳輸出為"低",即逐漸開燈。//設定數字I/O腳輸出為"低",即逐漸關燈。//設定數字I/O腳為輸出。//第一颗LED 接的 I/O 脚。delay(200);delay(200);
·
int BASE = 2 ; //第一颗LED 接的 I/O 脚
int NUM = 6; //LED 的个数
void setup()
{
for (int i = BASE; i < BASE + NUM; i ++)
{
pinMode(i, OUTPUT); //設定數字I/O腳為輸出
}
}
void loop()
{
for (int i = BASE; i < BASE + NUM; i ++)
{
digitalWrite(i, LOW); //設定數字I/O腳輸出為"低",即逐漸關燈
delay(200); //延遲
}
for (int i = BASE; i < BASE + NUM; i ++)
{
digitalWrite(i, HIGH); //設定數字I/O腳輸出為"低",即逐漸開燈
delay(200); //延遲
}
}
更多推荐
所有评论(0)