Looking for a location for user-created headers

Well, I've run into another problem now that I've got my problem with assigning pointers to elements of arrays straightened out. I'm dealing with a couple of large arrays of numbers, and I was hoping to store them in a header file so they wouldn't clutter up the code, however when I put the header file in the sketch directory and do #include "arrays.h" the compiler can't find it. Any ideas?

You would normally only put variables in a header if you were going to have them shared between several source files, and unless you’re very careful with the declaration, you could end up with more than one instance of the variable.

I don’t see how two arrays can clutter up code.
Keep it local - it avoids all kinds of potential hassle.

I don't see how two arrays can clutter up code.

They're wavetables for direct digital synthesis - each array has 255 1 byte values, and I eventually will need 4 of them. It's a lot of stuff to have sitting at the top of my sketch... :o

It's a lot of stuff to have sitting at the top of my sketch...

So, put them at the bottom of your sketch, with a forward extern reference at the top. 8-)

You probably have them in the wrong directory. Assuming you're Windows based, and the name of your library file is WaveTableArray.h

1) put the file in a folder named WaveTableArray 2) put this folder in arduino-0015\hardware\libraries\ (or whereever your aduino files are) Note: this is NOT the directory in My Documents where you store the sketches)

Good luck!

Why not put them as a separate tab in the IDE?

I’m not familiar with tabs and a quick search didn’t turn up how to use them. Could you point me to an instruction page? Thanks.

Never mind. I found it: http://www.arduino.cc/en/Hacking/BuildProcess

And the relevant stuff:

Multi-file sketches
A sketch can contain multiple files (tabs). To manage them, click on the right-facing arrow just above the scroll bar near the top of the environment. Tabs have one of four extensions: no extension, .c, .cpp, or .h (if you provide any other extension, the period will be converted to an underscore). When your sketch is compiled, all tabs with no extension are concatenated together to form the “main sketch file”. Tabs with .c or .cpp extensions are compiled separately. To use tabs with a .h extension, you need to #include it (using “double quotes” not ).

Sorry for the delay in my reply, I had been on vacation for a while. I've come back to this problem, and unfortunately I still can't get adding files to the sketch to work. Putting it in my libraries folder as a .h file doesn't work (no such file or directory), and when I select "Add File" from the Sketch menu and select the file I want to add, no tab is added - nothing happens at all. Any ideas?

Edit: I have it working now, I found the little arrow button at the far right of the environment (couldn't see it hiding over there!) and created a tab, then pasted in my data. Unfortunately, I've hit another problem, in that when I declare arrays or variables in this new tab the main sketch file doesn't "see" them when it compiles and I keep getting "not declared in this scope" errors.

Edit again: If I declare the arrays in both the main program and the tab, I get a variable redefinition error...if I declare the arrays just at the top of the main program, everything compiles fine. So it seems like maybe there's some kind of ordering issue with the compiler where it's looking at the main program first and causing an error when it hasn't yet looked at the tab where the variables are defined? :-?

You have to manually erase the .o file before compiling, or the library won’t be recompiled.