including a data file separately in a sketch

Hi,

I am trying to run the PCMAudio code as shown here:

http://playground.arduino.cc/Code/PCMAudio

which has the statement:

#include "sounddata.h"

sounddata.h has 2 statements, both declaring variables (as shown on the above webpage):

const int sounddata_length=10000;

const unsigned char sounddata_data[] PROGMEM = {128, ... }

I have researched where to locate the sounddata.h file for compiling and found various ideas such as:

which states to place it in the following dir:

{Arduino}\hardware\libraries directory

I don't have this directory but if I create it and put sounddata.h there in a subdirectory named "sounddata" or by itself I get this error:

"
speaker_pcm:67: error: expected ',' or ';' before 'int'

int ledPin = 13;
"

I also tried a number of other directories including the sketch folder, the main library folder, and C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries; within a subfolder and without.

What should I do to make this compile correctly?

Thanks

Just put the .h file in the same directory alongside your .ino file.

...R

why don't you just add the files to your sketch rather than in the system libraries? easier to debug for the time being.

Yes I did include the data directly in a similar sketch but it is ~30,000 bytes and that's a lot of scrolling if you want to modify the sketch, it would be more efficient to work with as a separate file.

Robin2 - I did try this, with and without a subdirectory "sounddata"

I also shortened the data file to ~100 bytes to see if it was the length of it, same error.

speaker_pcm:67: error: expected ',' or ';' before 'int'

int ledPin = 13;

Well here's a case where the root cause of the error was just as simple as compiler stated, I simply forgot the semicolon at the end of the variable declaration in the data file. I got used to recent compiler errors as being complex and difficult issues but not this one!

Thanks for your help.

:slight_smile: