Writing sketches with multiple files. How?

I am still learning.

All/most of the sketches I have seen are not just one file.

There are several other files of sketch stuff also loaded. These are not to be confused with .h, .cpp etc files.

I am writing a new sketch and would like to (maybe) break things up a wee bit to help keep things separated.

But I don't know how to do that.

Otherwise how do I mark the "end" of the program/sketch?

Just put the files in the same folder as your main sketch. Restart the IDE and they will appear as tabs in the edit window.

On the right side of the IDE, there's a little down arrow button. If you click it, you can add another file. I believe files without any extension (Like "foo" not "foo.cpp" or "foo.txt") will simply get added on to the bottom of your main sketch when it compiles.

If the extension is ".h" then you have to "#include" it, and if it's ".c" or ".cpp" it gets compiled separately. Don't worry about those too much.

Thanks.

This functionality appears to be seriously broken EXCEPT if you use the .pde files, i.e. the files with no extension.

There are numerous other reports of problems - for example to do with the order of automatic inclusion if you use no extension.

I've filed a bug
http://code.google.com/p/arduino/issues/detail?id=993&thanks=993&ts=1343511409

relating to my test sketch

Sample sketch to illustrate the problem
-----sketch-------
#include "test.h"
void setup() {
// Do nothing
}
void loop() {
bar();
}
#include "test.c";
-----test.h -----
void bar();
-----test.c-----
#include <WProgram.h>
int foo = 1;
void bar() {
// Do nothing
}