The code works and a sound is played when using the code given in the tutorials here: https://learn.adafruit.com/adafruit-wav ... o/play6-hc
however when I try to import those libraries, then use a function to read the SD card. The initialization fails.
When I try the following code, where ParseData is a function defined later that uses the SD.open() and file.read() etc., the serial port outputs nothing at all:
Code: Select all
#include <SD.h>
#include <FatReader.h>
#include <SdReader.h>
#include "WaveUtil.h"
#include "WaveHC.h"
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the filesystem on the card
FatReader f; // This holds the information for the file we're play
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
File myFile; //used with SD card reader
char wavArray[6][13]; //actArray[i][j] refers to ith row jth column
char actArray[6][13]; //actArray[i][j] refers to ith row jth column
char list[12][13]={"L1.txt"}; //actArray[l][j] refers to lth row jth column, l is the stack number
int k=0; //stack index, starts at 0, list[0]="L1"
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin()) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
char list[12][13]={
"L1.txt","L2.txt","L3.txt","L22.txt","L23.txt","L24.txt" };
for (int k=0;k<6;k++){
int n=ParseData(list[k]);
Serial.println("wavArray: actArray: current list: ");//print out wavArray, actArray, stack number, and current list name
for(int q=0;q<n;q++){
Serial.print(wavArray[q]);
Serial.print(" ");
Serial.print(actArray[q]);
Serial.print(" ");
Serial.println(list[k]);
}
delay(1000);
}
}
void loop()
{
}
}
Code: Select all
#include <SD.h>
//#include <FatReader.h>
//#include <SdReader.h>
//#include "WaveUtil.h"
//#include "WaveHC.h"
//
//SdReader card; // This object holds the information for the card
//FatVolume vol; // This holds the information for the partition on the card
//FatReader root; // This holds the information for the filesystem on the card
//FatReader f; // This holds the information for the file we're play
//
//WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
as you can see, I am not even getting past SD.begin. Is there something in your libraries that prevent or overwrite the SD.h functions?Initializing NNR+¥ ±¥é¥¹NNR+¥ ±¥é¥¹NN
I have tried various combinations of libraries but they all seem to be incompatible with SD.h, I cant seem to find a good source for what these libraries actually define either so I'm having trouble knowing how to use them.
Thanks