I am trying to write a class/function that I think I will be using often in my Arduino IDE, I know the code but where should i save the file so that the IDE picks it up without a full directory address in the #include line, as you may guess I'm a little new to this....

  • You can make a header files and put it in the default search path for the compiler, or instruct the IDE to add your header-file path to the paths the compiler uses for header files. But that's only for header files. If you want source to go along with it, you should make a (static) library of your code, and put it in the linkers default search path, and tell your project to link with your library.
    – Joachim Pileborg
    Jul 25, 2014 at 7:56

1 Answer 1


If you think you will be reusing this code frequently, you might want to make a library as suggested by Joachim. Your library can then be added to any sketch you write using a #include statement.

The arduino website has a nice guide on writing libraries, check it out here.

If you would just like to include your header file in a sketch without writing a library, placing the header file in the same directory as your sketch should compile if you use #include "header_file_name.h".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.