I cant find my mistake playing a wav file from an sd card

Hello
i am trying to play a wav file from an sd card on a speaker
but it doesn't work. I have already checked the function of the SD card reader and the speaker and I am actually sure that the code is correct.
i hope someone can find my mistake,
Thank you in advance

my code:

#include "SD.h" 
#include "TMRpcm.h" 
#include "SPI.h" 

TMRpcm tmrpcm;


void setup() {
 tmrpcm.speakerPin = 9;
 Serial.begin(9600);
 if (!SD.begin(4)) {
 Serial.println("SD fail");
 return;
}


tmrpcm.setVolume(5);
tmrpcm.play("herz.wav");

schaltung

is that all the code??
no, loop??

sorry.. ~q

Port pins cannot directly drive a speaker. They tend to burn out if you try, so use an audio amplifier.

I am actually sure that the code is correct.

Great, but what you posted is not correct.

yes i got most of the code of a website and was wondering about that too. i tried this code but had the same results:


#include "SD.h" 
#include "TMRpcm.h" 
#include "SPI.h" 

TMRpcm tmrpcm;


void setup() {
 tmrpcm.speakerPin = 9;
 Serial.begin(9600);
 if (!SD.begin(5)) {
 Serial.println("SD fail");
 return;
}


tmrpcm.setVolume(5);
tmrpcm.play("herz.wav");

}

void loop() {
tmrpcm.setVolume(5);
tmrpcm.play("herz.wav");

}

thank you for the help
do the speakers tend to burn through or the ports and doesnt that depend on the strenght of the speaker?

The ports burn out.

Code is still wrong. Don't waste any more time with that web site.

Good luck with your project.

not really helping
any idea what i did wrong?

Copying absolute junk off of a random web site.

#include "SD.h" 
#include "TMRpcm.h" 
#include "SPI.h" 

TMRpcm tmrpcm;


void setup() {
 tmrpcm.speakerPin = 9;
 Serial.begin(9600);
 if (!SD.begin(4)) {
 Serial.println("SD fail");
 return;
}
tmrpcm.setVolume(5);
tmrpcm.play("herz.wav");
}

void loop(){
//
}


the port doesnt seem to be destroyed i tried with different projects i wrote before. is there an error in the code or is it just dangerous for the arduino?

thank you but still not working

this is the article from steemit i found the code in: Playing music in Arduino using SD Card Module — Steemit

comparing it to..
Example: basic.ino
from the libs Git..
don't see any extenstions ".wav"??
only thing i see different..
lol, just noticed, the includes are wrong..
should be <> not ""..

sorry, good luck.. ~q

Yes, very obvious errors. They are obvious on the web site you linked, as well. The web site code never could have worked.

Why bother to post on the forum if you refuse to accept the answers and advice given?

I spent a few minutes looking on the web for a better tutorial along those lines, and found nothing but bad advice.