Arduino Forum

Using Arduino => Audio => Topic started by: vuga419 on Jun 11, 2014, 06:13 am

Title: wav files not playing on nano
Post by: vuga419 on Jun 11, 2014, 06:13 am
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:
(http://i.imgur.com/oUL85rbl.jpg)

the speaker I'm using:
http://www.dx.com/p/50mm-3w-speaker-driver-unit-black-silver-118192#.U5YvMfldV8E (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 (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 (http://www.taydaelectronics.com/cd4050-cd4050be-4050-buffers-line-drivers-hex-non-inverting-ic.html)

tmrpcm library page:
https://github.com/TMRh20/TMRpcm/wiki (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/ (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?
Title: Re: wav files not playing on nano
Post by: johnwasser on Jun 11, 2014, 11:28 pm
Could the file format be wrong? 

"Main formats: WAV files, 8-bit, 8-32khz Sample Rate, mono."
Title: Re: wav files not playing on nano
Post by: vuga419 on Jun 11, 2014, 11:52 pm
this is what I'm trying to play:
(http://i.imgur.com/4xcX4uc.jpg)
Title: Re: wav files not playing on nano
Post by: johnwasser on Jun 12, 2014, 12:16 am
That looks right to me, unless "PCM" describes something other than raw samples.

Have you tried it on a UNO?
Title: Re: wav files not playing on nano
Post by: janost on Jun 12, 2014, 01:10 am
There are no differences between the Uno/Nano/Pro Micro.

When are you people going to learn?
Title: Re: wav files not playing on nano
Post by: vuga419 on Jun 12, 2014, 01:31 am
I tried it on an UNO yesterday in an act of desperation. No change.  A faint pop maybe, but other than that, nothing.
Title: Re: wav files not playing on nano
Post by: johnwasser on Jun 12, 2014, 01:33 pm
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.
Title: Re: wav files not playing on nano
Post by: vuga419 on Jun 12, 2014, 10:05 pm
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 (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/ (https://www.sdcard.org/downloads/formatter_4/). 

(http://i.imgur.com/QaXs1n6.jpg)
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.
Title: Re: wav files not playing on nano
Post by: Tuttut on Jul 11, 2014, 07:19 pm
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.