Save both files as a sketch. Then add the second sketch .pde file to your first sketch. Here is an example. It does nothing but verify the compiler finds the test function in the second sketch.
I saved this first sketch as filetest.
void setup()
{
}
void loop()
{
test();
}
I saved this sketch as test. Note no setup or loop functions.
void test()
{
}
Then select "Sketch - Add file". Find the test.pde file. Highlight and click OK.
Compile it.
SurferTim:
Save both files as a sketch. Then add the second sketch .pde file to your first sketch. Here is an example. It does nothing but verify the compiler finds the test function in the second sketch.
IThen select "Sketch - Add file". Find the test.pde file. Highlight and click OK.
Compile it.
Along these same lines, it is possible to create header files that can be #included in arduino sketches ?
I typically put my structure definitions, global variables, in separate header files
Along these same lines, it is possible to create header files that can be #included in arduino sketches ?
Of course. You can add a tab in the IDE and assign it a name with a .h extension. Or, you can create the file using any editor, and use the same process outlined above to add the file to your sketch folder.
Along these same lines, it is possible to create header files that can be #included in arduino sketches ?
Of course. You can add a tab in the IDE and assign it a name with a .h extension. Or, you can create the file using any editor, and use the same process outlined above to add the file to your sketch folder.
When I tried saving a file with a .h on it, the Ide renamed it- and saved it to a subdirectory under the current project directory.
(this is not good- for the IDE to have more control than the user)
Having an example of a multi-file project with #included .h files would be great documentation to add to arduino.cc.
(If I only knew how to get in touch with the site maintainer(s), I would ask them directly )
The IDE renamed it to Subdirectory\structures_d.pde
If you don't supply an extension, .pde is assumed, regardless of the actual contents of the file. I'm guess you didn't supply one, since the IDE does handle .h files correctly for me.
In the directory where I saved it.
I'm not creating a reusable library, just organizing my code into multiple files.
You can do this IF all the files are in the same directory. If you want to splatter them all over the place, the IDE is not for you.
Ideally, all files for a given project should be in the same directory, as in
That's not only ideal, it's required.
Using a .c extension is going to make life very difficult for you. Go with the flow and use .cpp. Trust me on this.
PaulS:
If you don't supply an extension, .pde is assumed, regardless of the actual contents of the file. I'm guess you didn't supply one, since the IDE does handle .h files correctly for me.
{/quote]
I gave the file an explicit .h extension.
PaulS:
You can do this IF all the files are in the same directory. If you want to splatter them all over the place, the IDE is not for you.
You're missing the point. I tried saving the header.h file in the directory the the main .pde file was. The IDE renamed it to header_h, and saved it to a subdirectory
under the project directory.
PaulS:
That's not only ideal, it's required.
Tell that to the IDE, apparently it doesn't know that
PaulS:
Using a .c extension is going to make life very difficult for you. Go with the flow and use .cpp. Trust me on this.
The main.c filename was just an example, to show that I want all files in the same directory.
My actual files have .pde for an extension. I didn't know I could rename them to .cpp.
I prefer .cpp myself, over PDE.
I wish the people who make Arduino & Processing would use different default extensions for each project.
PDE gets associated with the IDE that was installed last. If I want to double-click on a .PDE file, it launches the Processing IDE, not the Arduino IDE.
PaulS:
The _ is used to replace invalid characters in file names. I'm wondering if you tried to use comma h (inadvertently, of course) instead of dot h.
PaulS:
The main sketch file must have a .pde extension. Other files can use .cpp, .c. or .pde, depending on what is in the file.
Good to know. I'll try saving .h again to see what happens.
[quote author=PaulS
The main sketch file must have a .pde extension. Other files can use .cpp, .c. or .pde, depending on what is in the file.
[/quote]
I've just tried doing a File Save as, with .pde extension
The IDE renamed .PDE to _pde, and saved that file in a subdirectory under the current project directory.
It also displayed this in the bottom window of the IDE
The sketch name had to be modified. Sketch names can only consist of ascii characters and numbers (but cannot start with a number).
They should also be less than 64 characters long.
This is the exact same thing that happened when I tried saving a header file as header.h
I'm guessing it didn't like the . in the .PDE extension
I've just tried doing a File Save as, with .pde extension
Saving what? The extension must be defined when the file is created. It can not be changed later.
The IDE renamed .PDE to _pde, and saved that file in a subdirectory under the current project directory.
It also displayed this in the bottom window of the IDE
The IDE renamed .PDE to _pde, and added .pde
I've tried saving the file as junk.pde
The IDE saved it as Junk_pde\junk_pde.pde.
(where Junk_pde is a NEW subdirectory made by the IDE.)
The IDE expects a sketch of a given name, like junk.pde, to be located in a directory of the same name without the .pde extension, like junk. There can be other files in that directory, with .cpp, .h, and .pde extensions.
Open the IDE, which will create a new sketch with today's date as part of the name. Add a new tab. Give the file associated with that tab a name, like testing.h. Add another tab, with the name testing.cpp. Add a third tab, with the name functions.pde. Now, save the files, using File + save. Put the folder/sketch in C:\Temp.
Then, navigate to C:\Temp\sketch_<todays_date>. What is in that folder?
I just did this, and I have:
C:\Temp\sketch_oct07a containing
sketch_oct07a.pde
testing.h
testing.cpp
functions.pde