🚚 Free delivery on orders over: €35 Croatia • €60 EU • $100 US

How to install and use an Arduino library

How to install and use an Arduino library-Uncategorized

Type: Software

Difficulty: Beginner

Categories: Arduino Library

What is an Arduino Library?

When working with Arduino, you will inevitably come across a term called Arduino Library. You will find them useful very fast. Libraries allow you to replace long and complicated code with a simple function. Meaning, they will allow you to simplify complex tasks so you can focus on other things. Connecting to sensors, displays, and other modules is made simple with libraries. Best of all, they’re only used when the sketch you’re running needs them. You don’t need advanced C/C++ knowledge to use them, as they are simple to use at any skill level.

 

Most programming platforms will have libraries to use. The Arduino environment is no different. The Arduino IDE comes with some preinstalled libraries, but you can also download them, and even create your own. A lot of developers from all around the world write and share their libraries over the internet. One of the most common places to do so is Github. You can even find our libraries on our Github repository.

 

There are two main ways to install an Arduino library: through Arduino IDE and manually.

Installing a library through Arduino IDE

Installing a library through your Arduino IDE is very easy. You can simply use the “Manage Libraries…” option in the Tools menu. You can also find it in the Sketch menu under “Include Libraries”.

How to install and use an Arduino library

The Library Manager window will pop up. A list of installed or ready-to-be-installed libraries will show. Above it will be two dropdown menus and a search bar. With the first dropdown, you can search the libraries with type, such as updatable, installed, Arduino, recommended, etc. The second dropdown menu is to filter out the topic of the library, like communication, device control, display, sensors, etc. In the search bar, you can type a search term such as a name, and you’ll get filtered results. In this example, we will be using a DHT11 sensor Arduino Library.

How to install and use an Arduino library

When you hover with your mouse over a library, you will see an Install button. Some of the libraries will have a version to choose from. By default, the newest version is chosen, but you can choose the one you want from the dropdown.

 

Once the library is installed, go to Sketch > Include Library to use it. Simply find the wanted library on the list and click on it. The Arduino IDE will immediately add it at the start of your code.

How to install and use an Arduino library

Importing a .zip library

Under the “Include Library” option in the Sketch menu, you might have seen the “Add .ZIP Library…”. As you may have guessed, it is used to install the libraries which aren’t downloaded directly through the IDE. Rather, you can download the .zip file yourself. This is particularly useful when the IDE cannot find what you’re looking for through the “Manage Libraries” option.

 

When you click on “Add .ZIP Library”, you will be prompted to select the library you want to add.

How to install and use an Arduino library

Navigate through the directories to find it, click on the .zip file you’ve downloaded earlier, and open it. Your Arduino IDE will show a message “Library added to your libraries. Check ‘Include library’ menu”. You can find thereafter your newly installed library under Sketch > Include Library.

 

If an error message occurred when installing a library this way, you might have selected the wrong file to add. Try going through the process again. If it still shows you an error, you might want to try installing a different version of the library.

Manually installing a library on Windows

If for some reason you want to install the library yourself, it’s really easy to do. Download the .zip file on your computer the same way you did when importing it into the IDE. The file will contain everything you need. It might include examples as well if the author has included them.

 

Before doing anything with the downloaded file, you’ll first need to find the location of your sketchbook folder. You can do so by going to File > Preferences on the Arduino IDE. The menu that pops up should look something like this.

How to install and use an Arduino library

You will see your sketchbook location under the first option. Other options won’t be of interest to you for this tutorial. Once you know where your sketchbook folder is, go to the directory where you saved the .zip file. Simply cut it and paste it into the “libraries” folder inside your sketchbook. Once it’s there, all you need to do is extract the folder.

How to install and use an Arduino library

When the folder is extracted, you can delete the .zip file. The next time you open up your Arduino IDE, you will be able to find the installed library under Sketch > Include Library.

How to install and use an Arduino library

When the folder is extracted, you can delete the .zip file. The next time you open up your Arduino IDE, you will be able to find the installed library under Sketch > Include Library.

How to install and use an Arduino library

Uninstalling an Arduino Library

Uninstalling an Arduino Library is simpler than installing it. Find the sketchbook folder on your computer (same as in the “Manually installing a library” chapter). Go to the location and open the “libraries” folder. Select the folder containing the library you want to delete, and then simply delete it. Next time you open your Arduino IDE, there won’t be the deleted library under the Sketch > Include Library menu.

 

Libraries don’t take much space and most of the time there is no reason to remove them. If you don’t intend to use them again, though, and want to declutter the list, you can safely delete them. You can always install any Arduino Library again if you need to use it in the future.

Leave a Reply