/*
Arrays
Demonstrates the use of an array to hold pin numbers
in order to iterate over the pins in a sequence.
Lights multiple LEDs in sequence, then in reverse.
Unlike the For Loop tutorial, where the pins have to be
contiguous, here the pins can be in any random order.
The circuit:
* LEDs from pins 2 through 7 to ground
created 2006
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe
/*
EngeBOT Technology - adapted By Cirineu
www.engebot.com
www.linkedin.com/in/cirineu-carvalho-fernandes-20490a37
www.facebook.com/engebot.tecnologia
www.instagram.com/engebot.technology
br.pinterest.com/engebottechnology
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Array
*/
const int NbrLEDs = 9;
const int ledPins[] = {13, 11, 10, 12, 3, 2, 4, 5, 6 };
const int wait = 20;
void setup(){
for (int led = 0; led < NbrLEDs; led++)
{
pinMode(ledPins[led], OUTPUT);
}
}
void loop() {
for (int led = 0; led < NbrLEDs-1; led++)
{
digitalWrite(ledPins[led], HIGH);
delay(wait);
digitalWrite(ledPins[led + 1], HIGH);
delay(wait);
digitalWrite(ledPins[led], LOW);
delay(wait*2);
}
for (int led = NbrLEDs; led > 0; led--) {
digitalWrite(ledPins[led], HIGH);
delay(wait);
digitalWrite(ledPins[led - 1], HIGH);
delay(wait);
digitalWrite(ledPins[led], LOW);
delay(wait*2);
}
}
Comments