2

It is possible to split the project into server files. However, it looks like they all must be in the same folder with the.ino file.

Is it possible to split project into several folders? I’ve got several git repositories which I want to use in the same project and I can’t use them as libraries. Each repository must have its own folder…

  • What operating system are you using? – Majenko Dec 15 '19 at 22:28
  • @Majenko Win10. Does it matter for this case? All things are quite similar everywhere nowadays. – zhekaus Dec 16 '19 at 7:08
  • Yes you can. It works and many projects use subfolders. And NO, you will not see them in your Arduino IDE. As st2000 said, Arduino IDE is simple and people likes it because it is simple. If you want the control of your processor and code, use PlatformIO. – Adriano Dec 16 '19 at 9:43
  • @Adriano how? I can refer the headers in subfolders but Arduino IDE does not compile the definitions from subfolders. And, guys, how you even can call it simple? Looks like things are simple only for simple deeds. – zhekaus Dec 16 '19 at 10:46
  • If you have a header inside a subfolder, you can just call #include "subfolder/header.h" and it works. You can see this big project for example: github.com/xoseperez/espurna/tree/dev/code/espurna - but you will not see the files inside the Arduino IDE. Simple means, that if you don't have programming skills, you are able to open and edit something without loose time to find out what an IDE is and how it works. In future, with the PRO version, it will be easier to develop something... I hope ;) – Adriano Dec 16 '19 at 13:35
1

I will try to give an answer as it is not easy to understand what you mean.

Probably it is also better if you know how the Arduino IDE works, before try to make complex projects.

Short answer: Yes, it is possible

Normally, you have an ino-file, some other files and many libraries. If you want create something for your project, you can just create a folder inside the library folder.

But this is not what you want right?

You can create many folders inside your project and include any header inside your folders just with
#include "subfolder/yourfile.h"

The files will not be opened with your Arduino IDE.

You can also create your "mini library", so the compiler will compile it with your project. This library need to be in a subfolder called src. At this point it will be converted and compiled for your project.

Simple working example:
testsub.ino

#include "src/test.h"
Test *test = new Test();
void setup(){
  Serial.print(test->number());
}
void loop(){
}

Create a subfolder src and place your files:
test.h

class Test
{
public:
  Test();
  int number();
};

and
test.cpp

#include "test.h"
Test::Test() {
}
int Test::number() {
  return 95;
}

If you want another "library", you can create another subfolder called src.

| improve this answer | |
  • You know, that's finally quite something! Thank so much! However, how can I have extra subfolder with the same name src? – zhekaus Dec 16 '19 at 16:42
  • 1
    You need to place the second subfolder inside the src folder. And there, you can place another src folder. This is the only way at the moment. – Adriano Dec 16 '19 at 22:42

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.