zeete
April 19, 2023, 11:11pm
1
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");
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.
zeete
April 19, 2023, 11:37pm
4
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");
}
zeete
April 19, 2023, 11:39pm
5
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.
zeete
April 19, 2023, 11:40pm
7
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(){
//
}
zeete
April 19, 2023, 11:43pm
10
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?
zeete
April 19, 2023, 11:45pm
11
thank you but still not working
zeete
April 19, 2023, 11:50pm
12
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.