Last active
April 9, 2016 15:11
-
-
Save shawngrimes/9fab8fdeb2d180c88c4719ec050b9684 to your computer and use it in GitHub Desktop.
Basic Arduino sketch demonstrating analog output with a fade stepping LED.
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 ledPin=9; //Store LED pin number in this variable | |
void setup() { | |
//No need for setup this time | |
pinMode(ledPin,OUTPUT); //Setup pin 9 for OUTPUT | |
} | |
void loop() { | |
analogWrite(ledPin,0); //Turn the LED on pin 9 off | |
delay(500); //Wait 500 milliseconds | |
analogWrite(ledPin,63); //Turn the LED on pin 9 25% on | |
delay(500); //Wait 500 milliseconds | |
analogWrite(ledPin,126); //Turn the LED on pin 9 50% on | |
delay(500); | |
analogWrite(ledPin,189); //Turn the LED on pin 9 75% on | |
delay(500); | |
analogWrite(ledPin,255); //Turn the LED on pin 9 100% on | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment