Created
April 14, 2019 10:30
-
-
Save MatthiasKainer/f9ea2852324664784451f41dd828f0ae 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
const unsigned char LED_RED = 3; | |
const unsigned char LED_GREEN = 5; | |
const unsigned char LED_BLUE = 6; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(LED_GREEN, OUTPUT); | |
pinMode(LED_BLUE, OUTPUT); | |
pinMode(LED_RED, OUTPUT); | |
} | |
void loop() { | |
char leds[] = {LED_RED, LED_GREEN, LED_BLUE}; | |
int i; | |
for(const char &led : leds) { | |
for (i = 0; i < 255; i = i + 1) { | |
analogWrite(led, i); | |
delay(10); | |
} | |
} | |
for(const char &led : leds) { | |
for (i = 255; i >= 0; i = i - 1) { | |
analogWrite(led, i); | |
delay(10); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment