Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to make a project with multiple files

I am developing Arduino based system that will enlarge over time. At the moment it has only the humidity and temperature read functionality. But soon a door control, sound recording and gsm web client support will be added. I want all these to be included as libraries and used in the main part. I'm thinking of one ino file that includes all other modules and calls their functions. My question is what is the best and most clean way to do it?

like image 644
Ted Tedson Avatar asked Sep 30 '22 12:09

Ted Tedson


2 Answers

I recommend sticking with libraries and library directories with examples. A library for each component to be interfaced with. This will help in many ways. Such as debugging and reuse.

C:\Users\myself\Google Drive\Arduino\libraries\componentX\componentX.h
C:\Users\myself\Google Drive\Arduino\libraries\componentX\componentX.cpp
C:\Users\myself\Google Drive\Arduino\libraries\componentY\componentY.h
C:\Users\myself\Google Drive\Arduino\libraries\componentY\componentY.cpp
etc...

This keeps it modular and compartmentalized.

Notice I have changed the Arduino's IDE preferences to Google Drive. (Cloud backup and portability)

Then rather than one BIG INO file in your sketch folder

C:\Users\myself\Google Drive\Arduino\somethingBIG\somethingBIG.ino

implement INO files in the

C:\Users\mflaga\Google Drive\Arduino\libraries\component\examples.

directories. This makes it quick to publish the components on GITHUB or Google Drive to share between systems.

Then you can have a sketch file that ties all the components together into your main project.

C:\Users\myself\Google Drive\Arduino\somethingTOPlevel\somethingTOPlevel.ino

like image 81
mpflaga Avatar answered Oct 20 '22 16:10

mpflaga


You might want to take a look at the Bare Arduino Project.

For my own project Moti, I felt the need to leave the Arduino IDE and use better tools to develop my project. Having to symlink or move every libraries soon felt deeply cumbersome and I looked for another solution. At the same time I was discovering the power of Makefile and stumbled upon Sudar's incredible project: Arduino-Makefile.

I spent time organizing my folders and thought it could be useful for others.

You can think about the Bare Arduino Project as a framework for starting your own project.

I've taken the time to write a lot of documentation. You can learn more about the framework with the README.md and the Installation Instructions.

If you like it or feels like some stuff are missing, I'd love to hear your feedbacks and improvements.

Hope it helps! :)

like image 20
ladislas Avatar answered Oct 20 '22 17:10

ladislas