Adding a simple button thingy

This commit is contained in:
Dan Buch 2013-12-29 22:11:25 -05:00
parent 742fa9d141
commit 3b2d5d492e
2 changed files with 18 additions and 0 deletions

View File

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

View File

@ -0,0 +1,17 @@
const unsigned int BUTTON_PIN = 7;
const unsigned int LED_PIN = 13;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
const int BUTTON_STATE = digitalRead(BUTTON_PIN);
if (BUTTON_STATE == HIGH) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
}