Running multiple .ino files

I'm a newbie to Arduino and coding in general so I'm having a hard time trying to figure the problem out and googling cause I don't the exact term to search for.

I'm trying to build a project that uses multiple sensors with arduino uno and what I've done was code and test each of the sensor individually.

Now I want to combine them together in a master file and was wondering how do you go about doing that or is it even possible at all.

I have 4 different files, pulse.ino, BloodPressure.ino, BodyTemp.ino and SPO2.ino.

I want to do something like

pulse(PR);
BloodPressure(BP);
BodyTemp(temp);
SPO2(O2);

Serial.print(PR);
Serial.print(BP);
Serial.print(temp);
Serial.println(O2);

Is what I'm asking even possible in arduino or do I just have to go about combining the file manually, changing the conflicting names and make them run as functions.

BakedIkezor:
Is what I'm asking even possible in arduino or do I just have to go about combining the file manually, changing the conflicting names and make them run as functions.

Yes.
Yes.

well that's sucks, was hoping there's a way to do it like source.c and main.c, cause i know those are possible for PIC18 :frowning:

Time to start editing i guess, gonna b long a$$ .ino file for sure...

BakedIkezor:
well that's sucks, was hoping there's a way to do it like source.c and main.c, cause i know those are possible for PIC18 :frowning:

Time to start editing i guess, gonna b long a$$ .ino file for sure...

BakedIkezor:
Now I want to combine them together in a master file and was wondering how do you go about doing that or is it even possible at all.

Maybe you should rephrase your question a bit; you asked to incorporate them in a master file. You only need one ino file and the rest can be c/cpp/h files. It's just a GCC compiler and can do everything that normal GCC compilers can do.

You can have multiple .ino files in an Arduino sketch.

So if you create a "master" sketch, then do Sketch > Add File... and add each of your other sketches they will be copied into the sketch folder and you will see a tab appear for each file in the Arduino IDE editor.

Now, the problem is that you can only have one setup() and one loop() function, and can't have conflicting names in a project. So you can't just throw together multiple sketches that run individually. But you could make functions from the code in each of your sketches and then call those functions as needed from your single setup() and loop() functions, as shown in the code you posted.

I find the use of tabs in a large Arduino project very useful. I will frequently have one tab for global declarations, one for constant definitions, one for setup(), one for loop(), one or more for functions, and one for commented notes on the project. This makes it so I don't have to do so much scrolling to find something.

1 Like

This Simple Merge Demo may give you some ideas.

As others have said you can multiple .ino files or a single .ino file plus .h and .cpp files (too much choice :slight_smile: )

...R