Created
November 26, 2015 17:28
-
-
Save beratdogan/8fc37481d688818a613e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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