SD Card Audio 'char*' Error

All, for the life of me I can't get a wav. file to play using Uno with Micro SD Card Adapter. I think I'm getting the errors formatting the SD Card with wrong wav. file perhaps? Using FAT32, 16000Hz, Mono, 16-bit PCM

SD initialized properly with good read.

I have research all I could from forums but now I need to ask the pros. Yes, I suck at programming but this is how I learn, by you...

Here is my commands:


#include <SD.h>
#include <SPI.h>
#include <pcmRF.h>
#include <pcmConfig.h>
#include <TMRpcm.h>
#define SD_ChipSelectPin 4
TMRpcm tmrpcm;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
tmrpcm.speakerPin=9;
if(!SD.begin(SD_ChipSelectPin)){
  Serial.println("SD fail");
  return;
}
tmrpcm.setVolume(6);

  tmrpcm.play("test.wav");
  delay(1000);
  return;
}e

ERROR CODES:

/Users/Eric/Documents/Arduino/sketch_jul25b/sketch_jul25b.ino: In function 'void setup()':
/Users/Eric/Documents/Arduino/sketch_jul25b/sketch_jul25b.ino:20:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   tmrpcm.play("test.wav");

It's not an error, just a warning. Although warnings must be checked, this one is innocent and is just annoying.

This will probably fix it

char fileToPlay[13] = "test.wav";
tmrpcm.play(fileToPlay);

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

Warnings should be fixed. A future version of the compiler may decide that it's now an error.

TMRpcm.h is junk.
A DFRobot mini player is leaps and bounds better and costs about the same as a decent uSD module.

1 Like

not your fault but oversight of the library creator, they should mark param as const char *

Runaway_P, thanks for advice, I been reading your other forum input. Very helpful. The DFPlayer seem very simple to set up and wire, any truth to that? I am just trying to add a stupid 30 second audio startup sound for a project. Seems to be the hardest thing to do with an SDCard aside from landing on the moon.

As far as I'm concerned it's a lead-pipe cinch.
Be sure to get a genuine DFRobot miniplayer.

I've done the TMRpcm thing. There's no volume. After you add an amp you're > miniplayer $$.

(They have a minimum, there are probably a few other things you need anyway.)

Adafruit has a several good boards based on VS1053.

This one has a 3W Amp.
This one give you access to the I2S interface for digital audio.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.