Go Down

Topic: wav files not playing on nano (Read 3420 times) previous topic - next topic

vuga419

I'm trying to play sound files from my nano, but nothing comes out of the speakers except for a faint pop, and then nothing.   Here is my code:  

Code: [Select]
#include <TMRpcm.h>
#include <SD.h>

TMRpcm audio;

void setup() {
 Serial.begin(9600);
 Serial.print(F("\nInitializing SD card..."));
 if (!SD.begin(10)) {
   Serial.println(F("failed!"));
   return;
 }
 Serial.println("done.");

 audio.speakerPin = 9;
 audio.play("sound.wav");
}

void loop() {
 }


This is what my breadboard looks like:


the speaker I'm using:
http://www.dx.com/p/50mm-3w-speaker-driver-unit-black-silver-118192#.U5YvMfldV8E

the SD card reader I'm using:
http://www.ebay.com/itm/1pcs-SD-Card-Module-Slot-Socket-Reader-Read-And-Write-For-Arduino-ARM-MCU-IS-/271423472886?pt=LH_DefaultDomain_0&hash=item3f321984f6

IC I'm using:
http://www.taydaelectronics.com/cd4050-cd4050be-4050-buffers-line-drivers-hex-non-inverting-ic.html

tmrpcm library page:
https://github.com/TMRh20/TMRpcm/wiki

Any ideas on how I can troubleshoot where the problem is?  I was mostly following this guy's tutorial:
http://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/
the serial monitor says the card initialized properly, so what could be the problem?

johnwasser

Could the file format be wrong? 

"Main formats: WAV files, 8-bit, 8-32khz Sample Rate, mono."
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

vuga419

this is what I'm trying to play:

johnwasser

That looks right to me, unless "PCM" describes something other than raw samples.

Have you tried it on a UNO?
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

janost

There are no differences between the Uno/Nano/Pro Micro.

When are you people going to learn?

vuga419

I tried it on an UNO yesterday in an act of desperation. No change.  A faint pop maybe, but other than that, nothing.

johnwasser

Does the PCM library return any sort of useful error if it can't find the specified file?  Perhaps there is something wrong with the formatting of the SD card.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

vuga419

not with the TMRpcm library, but when I tried to use the Simple SD Audio library (http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio) it returns an error code 8 which means "card returned an error response for CMD17 (read single block)".

The software I'm using to format my card is https://www.sdcard.org/downloads/formatter_4/


The options available under format type are quick, full(erase) and full(overwrite). (I've been using erase or overwrite)
The options under format size adjustment are on or off.

I'm not really sure what the format size adjustment is, or the difference between full(erase) and full(overwrite), other than overwrite takes a lot longer to finish.

Tuttut

Hi,
this error is an indication that something is wrong with your SD card, your level-shifters or your wiring to the card. Have you set up the correct SD-ChipSelect pin in your code? It is done differently (#define in TMRpcm, setSDCSPin() in SimpleSDAudio). Maybe the level-shifter you picked is too slow for the operation - try to do something different, often the simple resistor dividers shown on the SimpleSDAudio website work pretty well.

Go Up