play wav file from sd card. No sound

I am trying to play the bomb.wav file through my arduino using the audio.ino file Trouble is, there is no sound. I have verified contact with sd-card through the SD-test.ino file which gives this (all ok) message:

Initializing SD card…Wiring is correct and a card is present.

Card type: SDHC
Clusters: 472406
Blocks x Cluster: 64
Total Blocks: 30233984

Volume type is: FAT32
Volume size (Kb): 15116992
Volume size (Mb): 14762
Volume size (Gb): 14.42

Files found on the card (name, date and size in bytes):
0.TXT 2019-02-09 16:15:28 0
BOMB.WAV 2019-02-08 16:58:50 108608
TEST.TXT 2000-01-01 01:00:00 18
TEST.WAV 2017-03-19 07:26:36 286382

I have tested the speaker/amplifier setup by connecting the pin 11 to speaker(instead of pin 5 when using audio.ino) and the sound comes through.

There is no “SD fail” message from the audio.ino when running it, indicating that there is contact between arduino board and sd card.

Can anyone point me in the right direction? I have run out of things to try.

SD_test.ino (3.6 KB)

audio.ino (397 Bytes)

audioWOSD.ino (138 KB) (90 KB)

name & part number of the module?

code, in code tags?

I think the library (TMRpcm) refuses to work on pin 5 and 6 because otherwise it could break delay(), millis() and micros(). So any PWM pin but those should work; although I do prefer pin 9 or 10 (3 if it's forced to use the timer2).

[quote author=Geek Emeritus date=1551457432 link=msg=4079076]
name & part number of the module?[/quote]
I don't think that's the problem; the card seems to function correctly. If not, CardInfo would have failed even at the first stage.

Card adapter is Catalex MicroSD card adapter ver.1.0
I have tried 3 different output pins, none of them work.

Forgot to mention that I (obviously?) used the audioWOSD.ino when testing amplifier setup.

Well, I tried pin 9 and suddenly it worked!! thanks a lot guys for help!

I tried pin 9 and suddenly it worked!!

I guess the library don't work on any PWM pin, only on those that belong to a 16-bit timer. This means that only in an Arduino Mega you could have more options.

Forgot to mention that I (obviously?) used the audioWOSD.ino when testing amplifier setup.

Couldn't say anything about that anyways. I don't know what PCM.h does (its code).

I have recently built a "complete" wav player with 3 buttons for control, and found out a lot of things about the TMRpcm library.

  1. Pin 9 in single/mono mode is audio output.

  2. Pin 10 is second audio output for simulated stereo output.

  3. When using the ethernet shield with sd card, pin 4 on the shield must remain unused, as that is the internal pin for the sd card to communicate with the arduino.

  4. If you have issues with pops, you have to go into your Arduino-libraries-TMRpcm(TMRpcm-master) folder, and edit the file pcmConfig.h file with Word Editor. (windows)
    -in that file there is //#define buffSize 128, delete the // and change 128 to 256. Save the file and exit, reload your sketch to your Arduino.

  5. If the sound is distorted, you may have the volume set louder than your speakers can handle. For mine, level 4 is the loudest they can handle. (It goes from 0-6). You can set the volume in your sketch to the max with tmrpcm.setVolume(4);

  6. If your sound still has pops, in pcmConfig.h delete the // in front of #define rampMega

  7. delete the // before #define SD_FULLSPEED if your track sounds weird.

there are more tips, but I can't think of them all right now.