2013-12-30 03:34:12 +00:00
|
|
|
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 &&
|
2013-12-30 05:00:35 +00:00
|
|
|
CURRENT_BUTTON_STATE == HIGH) {
|
2013-12-30 03:34:12 +00:00
|
|
|
if (ledState == LOW) {
|
|
|
|
ledState = HIGH;
|
|
|
|
} else {
|
|
|
|
ledState = LOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
digitalWrite(LED_PIN, ledState);
|
|
|
|
delay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldButtonState = CURRENT_BUTTON_STATE;
|
|
|
|
}
|