Storing Arduino Libraries for Easy Code Management and Functionality Expansion

Where Arduino Libraries Are Stored

Libraries are a way to offload functionality from your main arduino sketch into something much more manageable. They can make code much easier to read, especially when used regularly.

Libraries are small packages of code that provide your sketches with extra functionality. They can simplify complicated tasks like connecting to sensors and displays.

Documents

If you’re going to be using Arduino, it is a good idea to have the library folder set up on your computer. This will allow you to easily find and use pre-crafted libraries that make it easier for you to connect to sensors, displays, and other modules. Libraries simplify complex code with a single function, and they are only used when the specific sketch you’re running needs them.

The simplest way to install an Arduino Library is to choose Sketch > Include Library > Manage Libraries from the Arduino IDE menu. This will open a list of hundreds of libraries that have been submitted to the Arduino servers and approved for inclusion into the IDE. Choose the one you want, and the Library Manager will automatically ensure that the library gets installed correctly to your Arduino IDE libraries folder. Examples of libraries include EEPROM, which helps you read and write data to the Arduino’s electronically erasable programmable read-only memory; Firmata, which lets your Arduino communicate with other devices and software via standard communication protocols; and LiquidCrystal, which makes it easy for your Arduino to talk to most character LCD displays.

Libraries

Libraries are pieces of code that make it easy to perform complex programming tasks. Thousands of libraries are available for everything from controlling LCD displays to driving motors to reading sensors.

If you create your own library, it will be stored in the default libraries folder (which varies by operating system) under your sketch directory as a subdirectory named after the library. Libraries included in board packages are stored within the library subfolder of the board package folder.

The Arduino IDE has a library manager that can install libraries with the click of a button. To open the library manager, navigate to Sketch > Include Library. The library manager will show a list of installed libraries with a drop down menu and search bar for filtering.

Sketchbook

You can install libraries in a folder outside the Arduino software, called a sketchbook. The IDE checks the sketchbook at startup to determine which libraries it has installed. Libraries not present in the IDE can be added to the sketchbook by choosing Sketch > Include Library.

A sketch is a set of code files that make up a program. Typically, the name of the program is the name of the folder that contains the code. Each file in a sketch has an extension that defines it as a different part of the program:.ino (default) or.pde (deprecated).

Using a folder for your sketches makes it easy to find the ones you need and keeps them organized. This can also help prevent lost work in the event of a power failure or app shutdown. You can back up your sketchbook to iCloud or the local device. See the support article on backing up your sketchbook for more information.

Extras

Using libraries allows you to add extra functionality to your sketches, such as using complex hardware or including functions that would be difficult to program from scratch. They also enable you to learn new skills through a ‘learn by doing’ approach.

Library files are included in your sketch when you choose Sketch – Include Library. If the library is a standard Arduino one (those included in the latest release of the Arduino IDE, at time of writing (1.8.5)), it will be listed in the Library Manager window.

Alternatively, you can download libraries distributed as ZIP files and manually install them on your computer. To do this, select the green button “Code” in the Library Manager and follow the on-screen instructions. Once installed, the library will appear in the ‘Libraries’ menu when you open the IDE. If the ‘Libraries’ menu isn’t available, you need to restart the Arduino IDE and check that it has correctly recognised the library.

Dig deeper

Leave a Comment