How to have public functions in another file?

I use several functions for debugging and other code for common use. Can I store this in a separate .ino file? This would help me to keep the main file clean and small.

Any advice?

If you’re building locally, it’s pretty easy to do, and is discussed in this thread

If you’re using the online IDE, click on the ‘+’ symbol that the top right to add a new file to your app. Easy as that! :slight_smile:

Unfortunately, I do not compile localy. So going to CLI will be the next step?

Maybe you missed that bit? :wink: You can still use the online IDE no problem. :slight_smile:

If you’re using the online IDE, click on the ‘+’ symbol that the top right to add a new file to your app

How does this work? I can only add a new .cpp and .h file. But I want just to add a globaly file (.ino) where i can store common functions.

Because of how C++ compiles, it’s not possible to have another .ino file - to share definitions between files, they need to go in a header (.h) file.

After clicking ‘+’, you could try putting all your shared functions in the header file and leaving the .cpp file empty, sometimes that works.

1 Like

I will check that out, :slight_smile:

Great! It works. At least with this project.
Thanks for the info.