Skip to content

Instantly share code, notes, and snippets.

@erichowey
Created September 30, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichowey/863f4dc8427cba45a9fc to your computer and use it in GitHub Desktop.
Save erichowey/863f4dc8427cba45a9fc to your computer and use it in GitHub Desktop.
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