Introduction to the Arduino guide serieS

Arduino libraries and how to install them

In Lesson 5 of the introductory mini-course on the Arduino, you will learn about Arduino libraries.


A library is a software code that performs a particular function. It is distributed by its author so that other people that need this function can include it in their applications without having to write the equivalent code again.

In Lesson 5 of the introductory mini-course on the Arduino, you will learn about Arduino libraries.

A library is a software code that performs a particular function. It is distributed by its author so that other people that need this function can include it in their applications without having to write the equivalent code again.

Libraries can speed up and simplify prototyping significantly. When you install the Arduino programming environment on your computer, you also install a lot of frequently used libraries that you can use right away.

If there is a library that you need but is not included with the IDE, you can install it. We’ll look at an example shortly.

But first, why are libraries important?

Why libraries?

It’s simple: libraries allow you to be far more productive and effective because they make it possible for you to use existing, tested, high-quality code.

Imagine you are a mechanic, or a builder, or a tailor. As a mechanic, when you need a new part, you can either design it and create it yourself (a long, expensive, error-prone process) or order it from a spare parts vendor. If you are a builder and need bricks, you can either make them yourself (a long, expensive, error-prone process) or order them from the brickyard. If you are a tailor and you need some new fabric, you can either plant some cotton, harvest it, and produce your fabric out of it, or just buy it from the market.

As Makers, our objective is to create new things, things that solve a particular problem we have, or help us learn. The tools that we use, combined with our skill and knowledge, dictate how effective we will be in our making.

The Arduino is extraordinary in the technology world because of the abundance of shared and reusable code. Thanks to the Arduino libraries, it is possible for us to build our projects on the shoulders of other makers. This can make, even a beginner, very productive.

This is why I decided it is important to introduce you to libraries now, instead of waiting for a later time.

Let’s look at an example.

An example of a library and how to install it

Let’s say that you want to have a small web server running on your Arduino. You can set up this server so that you can use your browser to control lights and read sensor values connected to it. The Arduino can handle this, no problem. You could spend a few days (or weeks) and write your own bare-bones web server (assuming you have a good understanding of HTTP), or use Webduino.

Webduino is a library that was written at NYC Resistor to make it very easy to turn an Arduino into a basic web server.

The home page for Webduino on Github is https://github.com/sirleech/Webduino.

Including a new library

A new dialogue box will pop up. Browse to the location of the ZIP file, select it, and click on Choose to complete the process:

The Library addition dialogue box

When you click on “Choose,” the dialogue box will disappear, but nothing else is going to happen. No confirmation, no sound. To make sure that the Webduino library was installed, you can look for the example sketches that most libraries include.

Go to File → Examples, and look at the bottom of the list for your new library:

There’s the new library, right at the bottom of the list!

You can also find a list of names and descriptions of all the libraries currently installed in your IDE. Go to Sketch → Include Library → Manage Libraries, and this window will pop-up:

The library manager can tell you what’s installed and install new libraries.

The Library Manager, apart from telling you what is already installed, can also install new libraries from online sources with the click of a button.

You can add a new library from the Library Manager.

Now you should have a good overview of the IDE and its most essential functions. Let’s have a look at the Arduino programming language next.

Ready for a bit of programming? Continue with lesson 6.

New to the Arduino?

Arduino Step by Step Getting Started is our most popular course for beginners.

This course is packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up. We'll help you get started and at every step with top-notch instruction and our super-helpful course discussion space.

We publish fresh content each week. Read how-to's on Arduino, ESP32, KiCad, Node-RED, drones and more. Listen to interviews. Learn about new tech with our comprehensive reviews. Get discount offers for our courses and books. Interact with our community. One email per week, no spam; unsubscribe at any time

Image
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}