Adding a New Library to Arduino IDE and Using It
Once you are comfortable with the Arduino software and using the built-in functions, you may want to extend the ability of your Arduino with additional libraries.
The Arduino IDE provides several libraries that can be used to make many projects, but, sometimes, specialized hardware or software is needed.
What are Libraries?
Libraries are a collection of code that makes it easy for you to connect to a sensor, display, module, etc.
. For example, the built-in LiquidCrystal library makes it easy to talk to character LCD displays.
There are hundreds of additional libraries available on the Internet for download.
The built-in libraries and some of these additional libraries are listed in the reference.
To use the additional libraries, you will need to install them.
How to Install a Library
Installing Arduino libraries can be done in three different ways: manually installing the files, importing a ZIP file, and using the library manager.
Two of these methods can be done with menu options. But for manual installation, you have to locate the library’s files and place them into the Arduino “libraries” folder.
To install a new library into your Arduino IDE you can use the Library Manager.
Open the IDE and click to the "Sketch" menu and then Include Library > Manage Libraries.
Once loaded, you should see a window that looks similar to this:
From here, we can search for commonly used libraries and have the IDE automatically download and install them.
In our case, we will install an ESP8266 library so that we can connect our Arduino to an ESP8266 device.
Start by searching for “ESP8266” in the upper right box. Then wait for the results to appear in the window.
Select the library and then click the “Install” button.
Now we will install the ESP8266 library
While the installation takes place, we should see the bottom progress bar changing and displaying messages such as “Downloading”.
Installation taking place
Once completed, close the library
manager, open the IDE window, click Sketch > Include Library, and then look for “Arduino Uno WiFi Dev Ed Library”.
Click this option, and the IDE will automatically insert the header file into our project.
And that’s it!
new library in our library list!
Importing ZIP Libraries
Libraries can be imported from ZIP files that are often found online.
First, find the library that you want to include.
In this case, I will be getting an SD card read/write library, which can be found on GitHub.
First, download the library as a ZIP, which is done by clicking the green “Clone or download” button and then clicking “Download ZIP”.
Downloading the ZIP file
Once downloaded, go to the Arduino IDE and click Sketch > Include Library > Add .zip Library.
Adding a ZIP library
In the file dialogue windows that opens, locate your downloaded ZIP file.
For me, this file was downloaded to … you guessed it …. “Downloads”.
The downloads folder
Once opened, the IDE will freeze for a second or two.
Afterward, you should receive a “Library Added” message just above the debug window
The library has been added!
Finally, check that the installation was successful.
To do this, navigate to Sketch > Include Library and look for the installed library.
The Manual Way
Like the previous steps, we first need to find a library that we want to manually install.
For this example, we will install the Arduino sound library which can be found on GitHub.
The first step is to download the library as a ZIP, which is done by clicking the green “Clone or download” button and then clicking “Download ZIP”.
GitHub Download for the Arduino Sound library
Once downloaded, open the ZIP file and in a separate window and navigate to your Arduino folder.
This is usually found in your “Documents”, folder and in my example, it is located at C:\Users\RobinLaptop\Documents\Arduino.
Both windows side by side
In the Arduino folder, open the “Libraries” folder and then drag the “Audio-master” folder into the libraries folder.
Drag the library folder into the Arduino library folder
Restart the Arduino IDE and then check to see if the library has been detected by navigating to Sketch > Include Library.
Checking for the Audio library
Installing libraries on the Arduino IDE is incredibly easy, which means expanding your projects should be hassle-free.
Many of these libraries also come with examples and explanations, so you should have no trouble using them!