/*
  Arduino | general
  FRANKLYN — 12/14/24 at 5:14 PM
  Do u know what is wrong?
*/

const int NUM_SWITCHES = 7;
const int SW_PINS[] = {8, 7, 6, 5, 4, 3, 2};

int switchState[NUM_SWITCHES];
int oldSwitchState[NUM_SWITCHES];

void printState(int switchNum)  {
  Serial.print("Switch ");
  Serial.print(switchNum + 1);
  Serial.println(switchState[switchNum] ? " On" : " Off");
}

void setup() {
  Serial.begin(115200);
  Serial.println("Initial switch states:");
  for (int i = 0; i < NUM_SWITCHES; i++) {
    pinMode(SW_PINS[i], INPUT_PULLUP);
    switchState[i] = digitalRead(SW_PINS[i]);
    oldSwitchState[i] = switchState[i];
    printState(i);
  }
  Serial.println("Ready\n");
}

void loop() {
  for (int i = 0; i < NUM_SWITCHES; i++)  {
    switchState[i] = digitalRead(SW_PINS[i]);
    if (switchState[i] != oldSwitchState[i])  {
      oldSwitchState[i] = switchState[i];
      printState(i);
    }
  }
}
$abcdeabcde151015202530354045505560fghijfghij