1

I have some small functions to format numbers. I move them to a new file and I would like to import it to my proyect.

I can't find how to do it without defining a class (maybe it's the only way). I would like to import like JavaScript, PHP or other languages: just using the import word or something similar.

I know how to import libraries. Example:

#include <OneWire.h>
#include <DallasTemperature.h>
asked Nov 20, 2017 at 14:11

1 Answer 1

1

If the file is in your sketch folder then you use this syntax:

#include "foo.h"

All source files in the root of the sketch folder are shown as tabs in the Arduino IDE. In some cases that might not be desirable. If so, you can put the file in the src subfolder of your sketch folder and use this syntax:

#include "src/foo.h"

Or you might want to group files together into separate subfolders:

#include "src/foo/foo.h"

If you want to access the file from multiple sketches then you should turn it into a library and use this syntax:

#include <foo.h>
answered Nov 20, 2017 at 14:31

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.