const int buttonPins[] = {2, 3, 4, 5, 6}; 
const int ledPins[] = {7, 8, 9, 10, 11};
const int buzzerPin = 12; 
const int noteFreq[] = {262, 294, 330, 349, 392};

void setup() 
{
  for (int i = 0; i < 5; i++) 
  {
    pinMode(buttonPins[i], INPUT);
    pinMode(ledPins[i], OUTPUT);
  }
  
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Check for button presses
  for (int i = 0; i < 5; i++) 
  {
    if (digitalRead(buttonPins[i]) == HIGH) 
    {
      playNote(i); // Play the  note
      illuminateLED(i); // Illuminate the LED
      delay(500); // 
      turnOffLEDs(); // Turn off all LEDs
    }
  }
}

// play the note
void playNote(int noteIndex) 
{
  tone(buzzerPin, noteFreq[noteIndex]); // Play the note
  delay(300); // 
  noTone(buzzerPin); // Stop playing the note
}

//  illuminate the LED to the note played
void illuminateLED(int ledIndex) 
{
  digitalWrite(ledPins[ledIndex], HIGH); // Turn on the LED
}

// turn off all LEDs
void turnOffLEDs()
 {
  for (int i = 0; i < 5; i++) 
  {
    digitalWrite(ledPins[i], LOW); // Turn off all LEDs
  }
}
$abcdeabcde151015202530fghijfghij