play the wav file in sd card with a push button

I have been struggling with this for 1 week ,I can’t get the sound to play at all. I really appreciate if anyone can give me some clue.

#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10 //using digital pin 4 on arduino nano 328
#include <TMRpcm.h> // also need to include this library…
#include <SPI.h>
int buttonPin = 2; // button pin variable
int val = 0; // variable to read button pin value

TMRpcm tmrpcm; // create an object for use in this sketch
char mychar;

void setup(){

tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc

if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println(“SD fail”);
return; // don’t do anything more if not


void loop(){
val = digitalRead(buttonPin);
if (val == HIGH){“123.afm”);


Without f**king around with the switch, can you play the song in setup()? Is that even close to the proper extension? That is NOT the correct extension for a wav file.

Sry about that ,i am a noob at programming, So what should i do with the the switch? Thank u very much

So what should i do with the the switch?

Put it in a box. Tape the box shut.
Put the box in a drawer. Lock the drawer.
Mangle the key beyond usefulness.