diff --git a/arduino/UnreliableSwitch/Makefile b/arduino/UnreliableSwitch/Makefile new file mode 120000 index 0000000..51c7f30 --- /dev/null +++ b/arduino/UnreliableSwitch/Makefile @@ -0,0 +1 @@ +../arduino.mk \ No newline at end of file diff --git a/arduino/UnreliableSwitch/UnreliableSwitch.ino b/arduino/UnreliableSwitch/UnreliableSwitch.ino new file mode 100644 index 0000000..0a6d1f3 --- /dev/null +++ b/arduino/UnreliableSwitch/UnreliableSwitch.ino @@ -0,0 +1,21 @@ +const unsigned int BUTTON_PIN = 7; +const unsigned int LED_PIN = 13; + +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 == HIGH) { + ledState = HIGH; + } else { + ledState = LOW; + } + + digitalWrite(LED_PIN, ledState); +}