int d = 50; // The higher the number, the slower the timing.
void setup() {
// use a for loop to initialize each pin as an output:
for (int Pin = 0; Pin < 8;Pin++) {
pinMode(Pin, OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int Pin = 0; Pin < 8; Pin++) {
// turn the pin on:
digitalWrite(Pin, HIGH);
delay(d);
// turn the pin off:
digitalWrite(Pin, LOW);
}
// loop from the highest pin to the lowest:
for (int Pin = 7; Pin >= 0; Pin--) {
// turn the pin on:
digitalWrite(Pin, HIGH);
delay(d);
// turn the pin off:
digitalWrite(Pin, LOW);
}
}
No comments:
Post a Comment