A library is a group of functions and declarations, exposed for use in Arduino IDE scripts. The library therefore consists of an interface expressed in a .h file (named the “header”) and an implementation expressed in a .cpp file. The header file contains all the declarations and the .cpp file contains definitions of functions declared in the header file.
Libraries makes it easy for you to connect to a sensor, display, module, etc. For example if you want to control your evive TFT display, you can use evive Library. It has predefined functions to write text, draw line and many more. Hence you don’t have to make all the complicated functions on your own, you have to just use the corresponding library.
There are three ways in which you can install a library:
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. Scroll the list to find the library you want you install, then select the version of the library you want to install. Sometimes only one version of the library is available.
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 installed library. You can close the library manager.
Libraries are often distributed as a ZIP file or folder. For this example we will import evive library. You can download it from here. Generally, the name of the folder is the name of the library. Inside the folder there will be a .cpp file, a .h file and often a keywords.txt file, examples folder, and other files required by the library. 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 evive.zip file’s location and open it.
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.
To include a library in a sketch, navigate to Sketch > Include Library and select the library you want to include.
In this example we have included evive.h.