Skip to content

Instantly share code, notes, and snippets.

@beratdogan
Created November 26, 2015 17:28
Show Gist options
  • Save beratdogan/8fc37481d688818a613e to your computer and use it in GitHub Desktop.
Save beratdogan/8fc37481d688818a613e to your computer and use it in GitHub Desktop.
int pins[] = {7, 8, 9, 10, 11, 12, 13};
int pinsLength = sizeof(pins) / sizeof(int);
void setup() {
for (int pin = 0; pin < pinsLength; pin++) {
pinMode(pins[pin], OUTPUT);
}
}
void loop() {
for (int pin = 0; pin < pinsLength; pin++) {
fadeLedOn(pins[pin]);
}
for (int pin = 0; pin < pinsLength; pin++) {
fadeLedOff(pins[pin]);
}
for (int pin = pinsLength-1; pin >= 0; pin--) {
fadeLedOn(pins[pin]);
}
for (int pin = pinsLength-1; pin >= 0; pin--) {
fadeLedOff(pins[pin]);
}
delay(100);
}
void fadeLedOn(int pin) {
for (int i = 0; i < 256; i+=10) {
analogWrite(pin, i);
delay(1);
}
}
void fadeLedOff(int pin) {
for (int i = 255; i > 0; i-=10) {
analogWrite(pin, i);
delay(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment