0

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....

asked Jul 25, 2014 at 7:51
1
  • 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. Commented Jul 25, 2014 at 7:56

1 Answer 1

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".

answered Jul 30, 2014 at 13:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.