Created
October 20, 2017 13:12
-
-
Save duggan/e7d5a0dcd6070fad25462c4b334c56ba to your computer and use it in GitHub Desktop.
Arduino. Fading an LED in and out to produce a glow effect via the PWM pins.
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
/* Fading an LED in and out to produce a glow effect | |
via the PWM pins. | |
*/ | |
int timer = 10; | |
int pin = 3; | |
int val = 0; | |
void setup(){ | |
pinMode(pin, OUTPUT); | |
} | |
void loop(){ | |
while (val <= 220) { | |
analogWrite(pin, val); | |
val++; | |
delay(timer); | |
} | |
while (val >= 30) { | |
analogWrite(pin, val); | |
val--; | |
delay(timer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment