Adding debounce button thingy and dice + button version

This commit is contained in:
2013-12-29 22:34:12 -05:00
parent 244a3ee1a9
commit af850b2d91
4 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
const unsigned int BUTTON_PIN = 7;
const unsigned int LED_PIN = 13;
int oldButtonState = LOW;
int ledState = LOW;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
const int CURRENT_BUTTON_STATE = digitalRead(BUTTON_PIN);
if (CURRENT_BUTTON_STATE != oldButtonState &&
CURRENT_BUTTON_STATE == HIGH) {
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(LED_PIN, ledState);
delay(50);
}
oldButtonState = CURRENT_BUTTON_STATE;
}

View File

@@ -0,0 +1 @@
../arduino.mk