const int switchPins[] = {2, 3, 4, 5}; // Define the pins connected to the dip switches
const int ledPins[] = {6, 7, 8, 9}; // Define the pins connected to the LEDs
void setup() {
for (int i = 0; i < 4; i++) {
pinMode(switchPins[i], INPUT_PULLUP); // Set dip switch pins as inputs with internal pull-up resistors
pinMode(ledPins[i], OUTPUT); // Set LED pins as outputs
}
}
void loop() {
// Read the state of each dip switch and update the corresponding LED
for (int i = 0; i < 4; i++) {
int switchState = digitalRead(switchPins[i]); // Read the state of the dip switch
digitalWrite(ledPins[i], switchState); // Update the corresponding LED
}
}