Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Arduino Library Structure

Stephen C edited this page Jan 20, 2013 · 2 revisions

Getting Arduino to recognize libraries you write yourself is not difficult, but it isn't clear as to where you need to put the files once you've written them. Below is an example of a directory structure that the Arduino IDE was able to pickup without issue:

├── libraries
│   ├── ARLIB_Pololu_Servo
│   │   ├── pololu_servo.cpp
│   │   └── pololu_servo.h
│   ├── ARLIB_SDCard
│   │   ├── README.md
│   │   ├── SDCard.cpp
│   │   └── SDCard.h
│   └── test
│       ├── test.cpp
│       └── test.h
└── sailcode
    ├── COPYING
    ├── README.md
    └── sailcode.ino

Note a few things. First is that the root of this structure is your Arduino Sketchbook folder. If the Arduino IDE was able to detect your library it will show up under the menu Sketch->Import Library-> followed by the name of the folder that you put your library in. When you select your library from the list, it scans the folder for header files and puts include statements at the top of the file.

Libraries and version control

Given that Arduino requires all the libraries to reside in a folder within the sketchbook folder, it sort of separates the sailcode repository from the libraries folder.

-(Arduino Sketchbook folder)
|
|-.git (Root git folder)
|
|- libraries
|   |- ArduinoLibrary
|- arduino_sketch
    |- arduino_sketch.ino

The above would have the root git folder, the root of the repository encompass everything contained in the Arduino Sketchbook folder. The complication with this is that if someone runs git add . it will include everything, not just the sailcode and related libraries.

On the other hand, you could split the repository into several. You could put a repository inside the arduinio_sketch folder, then another inside each of the related repositories. This approach however means dealing with more than 3 different repositories, each of which would need to be updated and managed manually.

Finally, the approach I believe hits a middle ground is to have a git repository at the root of the libraries folder, which would include all user made repositories, and another in the arduino sketch folder. You may run into the same kind of problem of including too much if the contributer already has third-party libraries within their libraries, folder, however given that all team members seem to be new to Arduino, this shouldn't be a big issue.

Contributing to the main repository

The QMAST team is using GitHub not just for storing remote repositories, but also for managing issues, and pull requests. I would like to see each member have a fork of the repository they are working on in their own profile, and then send in a pull request whenever they want code to be published to the main QMAST repository.

Clone this wiki locally