What are Libraries?
Libraries are a collection of code that makes it easy for you to connect to a device like a sensor, a display or connect to a module.
For example, the DS18B20 Temperature Sensor Module.
There are hundreds of additional libraries available on the Internet for download.
To use the additional libraries, you will need to install them.
How to Install a Library
Using the Library Manager
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.
Then the library manager will open and you will find a list of libraries that are already installed or ready for installation. In this example, we will install the DHT Sensor library. Scroll the list to find it, then select the version of the library you want to install. Sometimes only one version of the library is available. If the version selection menu does not appear, don’t worry: it is normal.
There are times you have to be patient with it, just as shown in the figure. Please refresh it and wait.
Finally, click on install and wait for the IDE to install the new library. Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the DHT Sensor. You can close the library manager.
You can now find the new library available in the Include Library menu.
If you want to add your own library open a new issue on github.
Importing a .zip Library
For folder or Zip files are often the format Libraries are distributed. The name of the folder is the name of the library. Inside the folder will be a. CPP file, a .h file and often a keywords .txt file, examples folder, and other files required by the library. Starting with version 1.0.5, you can install 3rd party libraries in the IDE. Do not unzip the downloaded library, leave it as is.
In the Arduino IDE, navigate to Sketch > Include Library. At the top of the drop-down list, select the option to “Add .ZIP Library”.
You will be prompted to select the library you would like to add. Navigate to the .zip file’s location and open it. For Example See image below:
Return to the Sketch > Import Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.
NB: the Library will be available to use in sketches, but examples for the library will not be exposed in the File > Examples until after the IDE has restarted.
Those two are the most common approaches. MAC and Linux systems can be handled likewise. The manual installation to be introduced below as an alternative may be seldom used and users with no needs may skip it.
To install the library, first, quit the Arduino application. For example, if you’re installing a library called “Arduino test”, uncompressed Arduino test .zip. It should contain a folder called Arduino test, with files like Arduino test. CPP(C++) and Arduino test .h inside. (If the.cpp and.h files aren’t in a folder, you’ll need to create one. In this case, you’d make a folder called “Arduino test” and move into it all the files that we rein the ZIP file, like Arduino test .cpp and Arduino test .h.)
Drag the Arduino Party folder into this folder (your libraries folder). Under Windows, it will Likely be called “My Documents\Arduino\libraries”. For Mac users, it will likely be called “Documents/Arduino/libraries”. On Linux, it will be the “libraries” folder in your sketchbook.
Your Arduino library folder should now look like this (on Windows):
or like this (on Mac and Linux):
Documents/Arduino/libraries/Arduino Party/Arduino Party .h
There may be more files than just the .cpp and .h files so make sure they’re all there. (The library won’t work if you put the .cpp and .h files directly into the libraries folder or if they’re nested in an extra folder. For example: Documents\Arduino\libraries\ArduinoParty.cpp and Documents\Arduino\libraries\ArduinoParty\ArduinoParty\ArduinoParty.cpp won’t work.)
Restart the Arduino application. Make sure the new library appears in the Sketch > Import
Library menu. That’s it. You’ve installed a library!