void setup() {
Serial.begin(115200);
for(int i = 2; i <= 9; i++)
pinMode(i, OUTPUT);
}
unsigned long leddelay = 0;
int count = 0;
void loop() {
if (millis() - leddelay >= 500) {
// 關掉上一顆 LED
digitalWrite(count + 2, LOW);
// 更新計數器
count = (count + 1) % 8;
// 顯示目前計數值
Serial.print("count=");
Serial.println(count);
// 點亮新的一顆 LED
digitalWrite(count + 2, HIGH);
// 更新延遲時間
leddelay = millis();
}
}