#define NUM_LEDS 8 // Number of LEDs
#define SWITCH_PIN_START 2 // Starting pin for the DIP switch
void setup() {
for (int i = SWITCH_PIN_START; i < SWITCH_PIN_START + NUM_LEDS; i++) {
pinMode(i, INPUT_PULLUP); // Set DIP switch pins as inputs with internal pull-up resistors
pinMode(i + NUM_LEDS, OUTPUT); // Set corresponding LED pins as outputs
}
}
void loop() {
for (int i = SWITCH_PIN_START; i < SWITCH_PIN_START + NUM_LEDS; i++) {
int switchState = digitalRead(i); // Read the state of the switch
digitalWrite(i + NUM_LEDS, !switchState); // Turn on/off the corresponding LED based on the switch state
}
}