Please help me on the code modification

Hi all,
I am working on a system which allows me to control LED and mp3 by triggering infrared sensors. There are 6 infrared sensors, they control 6 LEDs and 6 mp3 correspondingly, for example, sensor 1 is triggered, LED 1 lights and mp3 1 sounds, sensor 2 is triggered, LED 2 lights and mp3 2 sounds...and so on.
I have a similar code with only one sensor, one LED and one Motor. But I’ve no idea about how to make it works as 6 combinations. Please help me modify it or give some suggestions. Thanks a lot.

// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 8;     // the number of the pushbutton pin
const int ledPin =  11;      // the number of the LED pin
const int MotorPin =  9;      // the number of the Motor pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

// counter to avoid the sleep mode 
long counter=0;
long timingForSleepMode=11500;

void setup() {
  
   // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
  
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
 pinMode(13, OUTPUT);
 pinMode(MotorPin, OUTPUT);
 
digitalWrite(MotorPin, LOW);
digitalWrite(13,HIGH);
  delay(3000);
  digitalWrite(13,LOW);  
  
 
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW) {     
    // turn LED on:    
    // play
    
    digitalWrite(ledPin, HIGH);  
    digitalWrite(13, HIGH);  
    delay(50);
    digitalWrite(ledPin, LOW);
    digitalWrite(13, LOW);  
    //wait 5 seconds
    //delay(5000);
    
   digitalWrite(MotorPin, HIGH); 
    delay(5000);
   digitalWrite(MotorPin, LOW);  
    delay(10);
    
    // turn pause
    digitalWrite(ledPin, HIGH);  
     digitalWrite(13, HIGH); 
    delay(50);
    digitalWrite(ledPin, LOW); 
    digitalWrite(13, LOW); 
    delay(50);
    
    // counter time 
    counter=millis();
timingForSleepMode;
  } 
  // cut off motor
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
   digitalWrite(MotorPin, LOW);  
   
   //avoid sleep mode mp3
      if ((counter+timingForSleepMode)==millis()){
        digitalWrite(ledPin, HIGH);  
     digitalWrite(13, HIGH); 
    delay(50);
    digitalWrite(ledPin, LOW); 
    digitalWrite(13, LOW); 
    
    counter=millis();
      }
  }
}
timingForSleepMode;

What is this supposed to be/do?

      if ((counter+timingForSleepMode)==millis()){

Exact matches are not the best idea.

Please help me modify it or give some suggestions.

Put the code in a function, taking some pins as arguments. Call that function 6 times, for each sensor and mp3 pin.