// https://wokwi.com/projects/400705943055154177
// Demo of:
// DIP switch, 
// INPUT_PULLUP, 
// Change Detection, 
// auto & with array

const byte pins[] = {4, 5, 6, 7, 8, 9, 10, 11};
byte state [8] ;

void setup() {
  Serial.begin(115200);
  for ( auto &pin : pins) {
    pinMode(pin, INPUT_PULLUP);
  }
}

void loop() {
  for ( auto &pin : pins) {
    int ii = &pin-pins; // trick to calculate index
    if (digitalRead(pin) != state[ii] ) { 
      state[ii] = ! state[ii];
      Serial.print(pin);
      Serial.print(":");
      Serial.print(state[ii]);
      Serial.print(' ');
    }
  }
}