Trouble with a Circuit that Plays a WAV File from an sd card

I am having trouble with my circuit. I am trying to make a circuit that will play a wav file that I have uploaded onto an sd card. An sd card module is connected to the arduino board with a speaker. I have already formatted the WAV file correctly and I am honestly not sure what I am doing wrong. All the components have been tested and they all work. I am not sure if I coded something incorrectly. I would really appreciate it if someone could help me out with this. The code is below.

include "SD.h"

define SD_ChipSelectPin 10

include "TMRpcm.h"

include "SPI.h"

TMRpcm tmrpcm;

void setup() { tmrpcm.speakerPin=9; Serial.begin(9600); if(!SD.begin(SD_ChipSelectPin)) { Serial.println("SD fail"); return; } tmrpcm.setVolume(6); tmrpcm.play("test");

}

void loop() { // put your main code here, to run repeatedly:

}

I am also using an Arduino UNO board and I am able to upload a code and the code is verified and compiled. The weird thing is that IDE says that it is uploaded onto the board but no sound is being played at all. Therer is no error found when I try to upload

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.

Posting tips.

  • Your OS and version can be valuable information, please include it along with extra security you are using.
  • Always list the version of the IDE you are using and the board version if applicable.
  • How to insert an image into your post. ( Thanks Robin2 )
  • Add your sketch where applicable but please use CODE TAGS ( </> )
  • Add a SCHEMATIC were needed even if it is hand drawn
  • Add working links to any specific hardware as needed (NOT links to similar items)
  • Remember that the people trying to help cannot see your problem so give as much information as you can

Does [u]tone()[/u] work? That will check you amplifier, speaker and related connections.

The weird thing is that IDE says that it is uploaded onto the board but no sound is being played at all.

That is not weird. All the compiler cares about it that the syntax of the code you wrote is sufficient for it to be able to translate it into machine code. What that machine code does when it actually runs is down to your code and the associated hardware connected to your Arduino.

The compiled can not possibly know if your code will do what you want because it can not read your mind only your code.

It looks like you have connected the player to pins 0 and 1. That means it only stands a chance of working if you disconnect it from the USB port. Then you will need to supply power to the Arduino separately.

tone() is working when I ran a code that played a simple buzzing pattern.

I am currently making a project to play an audio(WAV) aloud using an 8 ohm speaker, a micro sd card, a micro sd card module and an Arduino uno. I have tried numerous tutorials and such to try and generate a sound but the audio will simply not play. When I tried to listen, there was no sound. When it was connected to a larger self powered speaker, only static would play. The module is working because it was able to write and interact with the sd card. The speaker is working because when I used the tone() function I was able to ply a series of beeps. At this point I am willingness to completely start over but it needs to happen soon. If anyone had an idea of how I can use the above materials to create something which will play a WAV file, please help me.

i have used this library and it works:

https://github.com/TMRh20/TMRpcm

however since arduino chips are not really intended for the purpose. the playback is somewhat low quality and mono and eats up all your board's proccessing power while playing. also you need to convert your wavs to a very specific format and sample rate.

you can get little mp3/wav player modules for very cheap that can be controlled by arduino. they are much easier to set up, you usually don't have to reformat your sound files. they play higher quality and they playback in stereo. and most sopport mp3 too.

ive tryed a couple different ones and I reccommend an YX5300. seems to be the easiest hookup and works well.

Parallel topics merged.

pert:
Parallel topics merged.

Don’t like the answer from Mom so ask Dad, classic. But as he is refusing to cooperate there is not much more we can do.

Grumpy_Mike:
It looks like you have connected the player to pins 0 and 1. That means it only stands a chance of working if you disconnect it from the USB port. Then you will need to supply power to the Arduino separately.

The SD card module is connected as so:

CS-10
SCK-13
MOSI-11
MISO-12
VCC- +5v
GND- arduino GND

The speaker is connected to the other arduino GND and pin 9.

What advice can someone give that will make this work. If you have a different schematic or code that you think will work better, I am completely open to that as well.

taterking: you can get little mp3/wav player modules for very cheap that can be controlled by arduino. they are much easier to set up, you usually don't have to reformat your sound files. they play higher quality and they playback in stereo. and most sopport mp3 too.

ive tryed a couple different ones and I reccommend an YX5300. seems to be the easiest hookup and works well.

How should I code this circuit in order to allow the audio to play? Also is there a specific brand of this module that needs to be bought? Thanks!

the chip you are looking for is a YX5300. comes right up with a google. im sure there are different people making them but they all work the same. has 4 wires total. power, ground and serial connection.

it also has the SD card slot built into the bottom of the module. all you have to do is give it basic serial commands to control it. should be simple enough to google a tutorial. if you have any problems let me know.

why no file extention? shouldn't it be:

tmrpcm.play("test.wav");

also have to make sure the file is encoded to the proper bitrate and wav format