box-o-sand/oldstuff/arduino/msaqsg/ch03/SimpleButton/SimpleButton.ino

18 lines
344 B
Arduino
Raw Normal View History

2013-12-30 03:11:25 +00:00
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);
}
}