Skip to content

Instantly share code, notes, and snippets.

@prasertsakd
Created July 22, 2015 08:39
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 prasertsakd/0d46691297780e6b7ed9 to your computer and use it in GitHub Desktop.
Save prasertsakd/0d46691297780e6b7ed9 to your computer and use it in GitHub Desktop.
int ledPin = 13;
boolean btn_up,btn_down;
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
for (int pin=6; pin<=13;pin++) {
pinMode(pin, OUTPUT);
}
digitalWrite(ledPin,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
btn_up = digitalRead(2);
btn_down = digitalRead(3);
if (btn_up == LOW) {
digitalWrite(ledPin,LOW);
delay(250);
ledPin++;
if (ledPin > 13) ledPin=6;
digitalWrite(ledPin,HIGH);
}
if (btn_down == LOW) {
digitalWrite(ledPin,LOW);
delay(250);
ledPin--;
if (ledPin < 6) ledPin=13;
digitalWrite(ledPin,HIGH);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment