/* Program by R. Jordan Kreindler Date: October 22, 2020 LED Display after rotary encoder switch is pressed */ #define Switch 9 byte val = 2; int delay1 = 75; #define firstLED 2 #define lastLED 7 void setup() { for (int i = firstLED; i <= lastLED; i++) { pinMode(i, OUTPUT); } } void loop() { val = digitalRead(Switch); if ( val == 0) { for (int i = firstLED; i < lastLED; i++) { digitalWrite(i, HIGH); delay(delay1); digitalWrite(i, LOW); } for (int i = lastLED; i >= firstLED; i-- ) { digitalWrite(i, HIGH); delay(delay1); digitalWrite(i, LOW); } } }