Created
December 25, 2013 15:14
-
-
Save dwyerk/8124123 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 green_led = 11; // 11 and 10 are pwm pins | |
int red_led = 10; | |
int max_brightness = 255; | |
int brightness_step = 5; | |
int delay_time = 20; | |
void setup() { | |
} | |
void loop() { | |
// fade in from min to max | |
for(int fadeValue = 0 ; fadeValue <= max_brightness; fadeValue += brightness_step) { | |
analogWrite(green_led, fadeValue); | |
analogWrite(red_led, max_brightness - fadeValue); | |
delay(delay_time); | |
} | |
// fade out from max to min | |
for(int fadeValue = max_brightness ; fadeValue >= 0; fadeValue -= brightness_step) { | |
analogWrite(green_led, fadeValue); | |
analogWrite(red_led, max_brightness - fadeValue); | |
delay(delay_time); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment