Need help to play a wav while another wav plays with SD module

im doing a project with arduino mega (2560) and two HC-SR04 sonar sensors and a SD module.

The purpose of my project is to play music(.wav) from the SD card which can play different .wav according to the distance.

Im new with arduino and imm not good in this programming, i have attached my code which i tried with 1 sonar and it needs to play different .wav with distance.

the issue here is i have asigned delay until a single wav plays. after only it gets the next signal.

i need it as that can continuously get signal without the delay to wait to play . and also according to 2 sonar have to play 2nd wav while the 1st wav plays...

please help me to solve this. i have to finish this project within a week. please kindly help me. im Thankful to you

wav_with_1snr.ino (2.33 KB)

The purpose of my project is to play music(.wav) from the SD card which can play different .wav according to the distance.

Using what hardware? The Arduino can not play wav files.

  while(distance <= 18 && distance >15){
   Serial.println("Playiing guitarc4.wav"); 
   Serial.println(distance); 
   tmrpcm.play("guitarc4.wav");
   delay(1000);
  }

Once it enters the while loop, what is going to make it stop looping?

using SD module we can play .wav files. my problem is to play 2 wav at a time

using SD module we can play .wav files.

Which module? On which Arduino? I have several Arduinos and three different SD modules. Only the SD module that is on the wav shield can ply wav files.

my problem is to play 2 wav at a time

Mine can't. I don't know about yours, since you won't tell us anything about it.

here i attached my sd module pictire and i used mega 2560 bord and the code i have uploaded before is a working code

F6VF1OJH5ENQ08B.MEDIUM.jpg

That module is not what is playing the wav file. It simply holds the wav file that the tmrpcm instance is reading and converting to noise.

We'd need a link to that library, at a minimum.

You need to first deal with the issue of using while statements where if statements are more appropriate.

YOU also need to test the ability of the library to play two wav files at once.