iNF { ⊙﹏⊙ } says to eric Yu xiang的窩🙄
/* For Loop Iteration Demonstrates the use of a for() loop. Lights multiple LEDs in sequence, then in reverse. The circuit: * LEDs from pins 2 through 7 to ground created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/ForLoop */ int pinCount = 4; // the number of pins (i.e. the length of the array) int timer = 100; // The higher the number, the slower the timing. int ledtimer[] = { 3000, 1000,3000,1000 }; int ledPins[] = { 2, 3, 5,6 }; void setup() { // use a for loop to initialize each pin as an output: for (int thisPin = 0; thisPin < pinCount; thisPin++) { pinMode(ledPins[thisPin], OUTPUT); } pinMode(4, OUTPUT); pinMode(7, OUTPUT); } void loop() { // loop from the lowest pin to the highest: for (int thisPin = 0; thisPin < pinCount; thisPin++) { if (thisPin==0 || thisPin==1){ digitalWrite(7, HIGH); digitalWrite(4, LOW); } else { digitalWrite(7, LOW); digitalWrite(4, HIGH); } /* if (thisPin<2){ digitalWrite(7, HIGH); digitalWrite(4, LOW); } else { digitalWrite(7, LOW); digitalWrite(4, HIGH); } */ timer=ledtimer[thisPin]; // turn the pin on: digitalWrite(ledPins[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins[thisPin], LOW); } }