/* Programmer R. Jordan Kreindler October 10, 2020 Sketch to light LED if incremental rotary switch is pressed If switch is not pressed value = 1 or HIGH If switch is pressed value = 0 or LOW */ #define Switch 8 #define LEDPin 9 byte val = 0; void setup() { pinMode (Switch, INPUT_PULLUP); // Set the switch as input, so that when not pressed the value equals one (1) pinMode(LEDPin, OUTPUT); } void loop() { val = digitalRead(Switch); if (val == 1) { digitalWrite(LEDPin, LOW); // turn the LED Off } if (val == 0) { digitalWrite(LEDPin, HIGH); // turn the LED On } }