4
Demonstrates the use of a for() loop.
5
Lights multiple LEDs in sequence, then in reverse.
8
* LEDs from pins 2 through 7 to ground
15
This example code is in the public domain.
17
http://www.arduino.cc/en/Tutorial/ForLoop
20
int timer = 100; // The higher the number, the slower the timing.
23
// use a for loop to initialize each pin as an output:
24
for (int thisPin = 2; thisPin < 8; thisPin++) {
25
pinMode(thisPin, OUTPUT);
30
// loop from the lowest pin to the highest:
31
for (int thisPin = 2; thisPin < 8; thisPin++) {
33
digitalWrite(thisPin, HIGH);
36
digitalWrite(thisPin, LOW);
39
// loop from the highest pin to the lowest:
40
for (int thisPin = 7; thisPin >= 2; thisPin--) {
42
digitalWrite(thisPin, HIGH);
45
digitalWrite(thisPin, LOW);