Revisiting the first circuit with Arduino
4. for() loops
4.1. Flashing elegantly
void setup()
{
// use a for loop to initialise each pin as an output:
for (int thisPin = 9; thisPin < 14; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop()
{
// another for loop to turn a pins ON and OFF
// this time thiPin is decreasing (--)
for (int thisPin = 13; thisPin > 8; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(500);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}