Skip to content

Instantly share code, notes, and snippets.

@baydam
Last active February 14, 2016 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baydam/648a39712b26d300547d to your computer and use it in GitHub Desktop.
Save baydam/648a39712b26d300547d to your computer and use it in GitHub Desktop.
// Range tous les pins sur un tableau, la j'ai choisi au hasard
int numeroPins[] = {10, 13, 2, 12, 11};
// Ici le nombre de lampe est 5 puisque le tableau contient 5 case
int nombreDeLampe = 5;
void setup() {
// Parcoure ton tableau pour setter le pin mode
for (int i = 0; i < nombreDeLampe; i++)
pinMode(numeroPins[i], OUTPUT);
// Joue le premier effet serpent une seul fois
for (int i = 0; i < nombreDeLampe; i++) {
digitalWrite(numeroPins[i], HIGH);
delay(500); // Joue avec le delay si tu veux
}
}
void loop() {
// Parcoure encore ton tableau pour clignote
// Pass 1: Allume les leds
for (int i = 0; i < nombreDeLampe; i++)
digitalWrite(numeroPins[i], HIGH);
delay(500); // Choisi un delai qui te convient
// Pass 2: Eteindre les leds
for (int i = 0; i < nombreDeLampe; i++)
digitalWrite(numeroPins[i], LOW);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment