Adding unreliable switch example
This commit is contained in:
parent
3b2d5d492e
commit
757deda43a
1
arduino/UnreliableSwitch/Makefile
Symbolic link
1
arduino/UnreliableSwitch/Makefile
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../arduino.mk
|
21
arduino/UnreliableSwitch/UnreliableSwitch.ino
Normal file
21
arduino/UnreliableSwitch/UnreliableSwitch.ino
Normal file
@ -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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user