I'm trying to make a project by combining two smaller projects, a recorder and a music player. The problem is that the integration between the two codes gives me a compiling error.
The recorder project uses the SdFat library, while the music player project is using both the SD library and the TMRpcm library (which I think is also dependent on the SD library).
I would like to resolve this dependency between the TMRpcm and SD libraries since it would be a lot easier than removing the dependency between the recorder code and the SdFat library, and run the whole code using just the SdFat library.
Even a simple sketch involving:
((#include "SdFat.h" #include "TMRpcm.h"))
would return an error
I think that the way to go is by modifying the TMRpcm library and make is dependent on SdFat rather than SD, but the problem is that I don't know C++ to modify it. I tried modifying it by opening as a .txt but have been unsuccessful so far. Please let me know if you can help.
Even a simple sketch involving:
((#include "SdFat.h" #include "TMRpcm.h"))
would return an error
From a quick look at the TMRpcm library it would appear that it can run with SD.h or SdFat.h
Indeed there is an example sketch with the library using SdFat. Here is the key instruction
The line #define SDFAT MUST be uncommented in pcmConfig.h
It is at line 49 in pcmConfig.h
/*
This example demonstrates how to use the SDFAT library for audio playback.
Read time and program space are reduced by using SDFAT directly
Requirements:
The SDFAT library must be installed. See http://code.google.com/p/sdfatlib/
The line #define SDFAT MUST be uncommented in pcmConfig.h
"error: 'File' has not been declared" means you need to read the above text
*/
#include <SdFat.h>
SdFat sd;
#define SD_ChipSelectPin 53 //use digital pin 4 on arduino Uno, nano etc, or can use other pins
#include <TMRpcm.h> // also need to include this library...
#include <SPI.h>
TMRpcm audio; // create an object for use in this sketch
void setup(){
audio.speakerPin = 11; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
pinMode(12,OUTPUT); //Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45
Serial.begin(115200);
if (!sd.begin(53, SPI_FULL_SPEED)) { return;
}else{ Serial.println("SD OK"); }
audio.play("song.wav");
}
void loop(){
if(Serial.available()){
switch(Serial.read()){
case 'p': audio.play("song.wav"); break;
default: break;
}
}
}