Created
September 30, 2015 04:49
-
-
Save erichowey/863f4dc8427cba45a9fc 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 leds = 9; | |
int increase = 12; | |
int decrease = 13; | |
int level = 20; | |
void setup() | |
{ | |
pinMode(leds, OUTPUT); | |
pinMode(increase, INPUT_PULLUP); | |
pinMode(decrease, INPUT); | |
analogWrite(leds, level); | |
} | |
void loop() | |
{ | |
if (digitalRead(increase) == LOW) { | |
if (level == 255) { | |
return; | |
} | |
analogWrite(leds, ++level); | |
} else if (digitalRead(decrease) == HIGH) { | |
if (level == 0) { | |
return; | |
} | |
analogWrite(leds, --level); | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment