Go Down

Topic: how to make and use a class (Read 1 time) previous topic - next topic

CosineKitty

OK, now I understand.  I too have had problems trying to #include a header file in the same directory as my sketch.  Looks like Arduino does NOT put the sketch directory inside the C++ include path.  But it looks like maybe you are trying to make a reusable library.  Try taking a look at this:

http://www.arduino.cc/en/Main/Libraries

bigengineer

I didn't start the thread for a reusable library. It was more to get my code more readable. So I figured that a class in another tab would be helpful. After reading this http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1167857708 thread I figured it would be easy to do.  :)


mellis

If the #include statement uses "double quotes", the compiler will check the directory that the including file is in (i.e. the sketch directory).  You just need to add to your sketch a .h file with the appropriate contents, and place the #include statement at the top of the main sketch file, and you should be fine.

bigengineer

#8
Jan 06, 2007, 10:36 pm Last Edit: Jan 06, 2007, 10:36 pm by bigengineer Reason: 1
But is this .h necessary? If you start a new tab the file will be saved as a .pde file. So, I expected that a #include  "onewire.pde" would work, but it doesn't.


Okay, I tried it. If I rename the onewire.pde to onewire.h and I use "#include "onewire.h" it works. And it gets better, if I save the file als foo.h it won't get the pde extension. But this might be something platform specific? (I am on OSX)
So, only one question left: why does .h work and .pde not?

Go Up