1
votes

I am working on a very long code that requires multiple functions defined.

I want to split the code into two files as main code ("Feeder_Control" in the screenshot) and functions ("connections" in the screenshot).

How to import the second file into main code to use its functions?

PS: In C/C++ same thing is done with #include "connections.h". How is it done in Arduino IDE.

1
You can create multiple tabs in the Arduino IDE to split up your code into separate files.Kokodoko
You may want to add this question to arduino.stackexchange.comBlundering Philosopher
have you tried #include "pathfoldername/connections.ino" ?Frenchy

1 Answers

1
votes

When you create a new tab in the IDE, you must set the file extension to either *.h/*.c/*.cpp. This will then tell the compiler what file you are referencing, otherwise you could be referencing anything. At the moment, connections doesn't have an extension, so the compile won't be able to understand your reference #include "connections.ino".

So, create a new file, and call it "Connections.h" (without quotes). Then in your main code, you can include using #include "Connections.h".