What are libraries?

The Arduino Integrated Development Environment or Arduino IDE software provides a simple interface to write code, compile it, and upload it to your Arduino compatible microcontroller. While the functions for many basic tasks such as turning pins on and off, simple communication, etc. are included in the “stock” libraries, many sensors have custom libraries available to make using them a snap. Installing these libraries takes just a minute and can save hours or even days of development time. Many companies selling breakout boards like Adafruit and Sparkfun have excellent libraries for many of their products.

There are three methods for integrating a new library into your Arduino IDE’s repertoire:

  • Adding via the Library Manager tab within the IDE
  • Using a zip file
  • Manual Installation of a Library Folder via the file browser

1. Using the Library Manager

This method is the fastest and easiest, but the library you are looking for must be listed in the Arduino package list to be found. Many are, but many more are not. This is the first place to look before using a more complex method though!

  1. Start by opening the Arduino IDE software. Then navigate to the library Manager window via the following path:

Sketch –> Include Library –> Manage Libraries

2. A new window will pop up after clicking Manage Libraries. In the search bar, type the title of your desired library. If the library is available, hover over it and click the install button located in the bottom right, then click close.
Once you have added your desired library, don’t forget to include the library at the top of your sketch via the code below. (Substitute You_library with the correct library name)
#include <Your_library.h>
Library Manager P1
Library Manager P2

2. Adding a .ZIP File Library

Adding a library via ZIP file is useful when adding third party libraries not listed on the Arduino package index. Many people provide the own libraries available on sites like GitHub, Bitbucket, GitLab, etc. Upon locating your desired library, download the ZIP file containing its code. On GitHub just look for the big green Download button!
  1. Open the Arduino IDE software and navigate the the .Zip File Selector window via the following path:

Sketch –> Include Libraries –> Add .ZIP Library

2. A file browser window will open. Navigate to the .ZIP file previously downloaded for your desired library.

3. Select the ZIP file and click open.

Once you have added your desired library, don’t forget to include the library at the top of your sketch via the code below. (Substitute You_library with the correct library name)
#include <Your_library.h>
.Zip Library P1
.Zip Library P2

3. Manual Installation

Manual Installation generally is not required, but sometimes things can get tangled up in the file system and it is nice to know where to find the libraries on disk.
  1. As you would with the ZIP file installation, the correct library file must be located and download from an external source.

2. Using an unzip utility such as the built in OS extractor, unzip the file into a temporary location.

3. Copy the extracted folder into the libraries folder in the Arduino File Structure.

Documents –> Arduino –> libraries

Restart the Arduino IDE and your new library should be available!

 

Once you have added your desired library, don’t forget to include the library at the top of your sketch via the code below. (Substitute You_library with the correct library name)
#include <Your_library.h>
Manual Lib P1
Manual lib P2

Still looking to learn more about Arduino Programming? Checkout our Arduino Learning Shield, which comes with its very own library to help you get stareted bringin your ideas to life! For even more help sign up for one of our online or in-person training courses!