I need to play a .wav file from a arduino uno for a science project, but i keep getting stuck on the code. I’m an absolute beginner to programming and really need help! sorry if this is something super easy to fix and I’m just to dumb to fix it.
Here is my code
#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h> // also need to include this library...
#include <SPI.h>
TMRpcm tmrpcm; // create an object for use in this sketch
void setup(){
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println("SD fail");
return; // don't do anything more if not
}
tmrpcm.play("Thomas.wav"); //the sound file "music" will play each time the arduino powers up, or is reset
}
void loop(){
if(Serial.available()){
if(Serial.read() == 'p'){ //send the letter p over the serial monitor to start playback
tmrpcm.play("Thomas.wav");
}
}
}
Here are the errors
D:\TMRpcm-master\examples\basic\basic.ino: In function ‘void setup()’:
D:\TMRpcm-master\examples\basic\basic.ino:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
tmrpcm.play(“Thomas.wav”); //the sound file “music” will play each time the arduino powers up, or is reset
^
D:\TMRpcm-master\examples\basic\basic.ino: In function ‘void loop()’:
D:\TMRpcm-master\examples\basic\basic.ino:28:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
tmrpcm.play(“Thomas.wav”);
I would deeply appreciate any help and advice