Skip to content

Instantly share code, notes, and snippets.

@flyingoctopus
Last active December 27, 2015 20:59
Show Gist options
  • Save flyingoctopus/7388976 to your computer and use it in GitHub Desktop.
Save flyingoctopus/7388976 to your computer and use it in GitHub Desktop.
even simpler
int pinCount = 4; // the number of pins
int thisPin;
void setup() { // set up the app
for (int thisPin = 1; thisPin <= pinCount ; thisPin++) {
setupPin(thisPin);
}
}
void loop()
{
for (int thisPin = 1; thisPin <= pinCount; thisPin++) {
turnOnPin(thisPin);
delay(300);
turnOffPin(thisPin);
}
}
void setupPin(int i) {
switch(i) {
case 1:
pinMode(A5, OUTPUT);
break;
case 2:
pinMode(A2, OUTPUT);
break;
case 3:
pinMode(10, OUTPUT);
break;
case 4:
pinMode(5, OUTPUT);
break;
}
}
void turnOnPin(int i) {
switch(i) {
case 1:
digitalWrite(5, HIGH);
break;
case 2:
digitalWrite(10, HIGH);
break;
case 3:
digitalWrite(A2, HIGH);
break;
case 4:
digitalWrite(A5, HIGH);
break;
}
}
void turnOffPin(int i) {
switch(i) {
case 1:
digitalWrite(5, LOW);
break;
case 2:
digitalWrite(10, LOW);
break;
case 3:
digitalWrite(A2, LOW);
break;
case 4:
digitalWrite(A5, LOW);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment