Created
July 22, 2015 08:39
-
-
Save prasertsakd/0d46691297780e6b7ed9 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 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