Introduction to the Arduino 

Lesson 5

Arduino libraries and how to install them

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

A library is 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 taylor. 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 taylor 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 makes can make, even a beginner, very productive.

This is why I decided that 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 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 Webuino 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, it 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 it’s most essential functions. Let’s have a look at the Arduino programming language next.

"Introduction to the Arduino" series

Ready for some serious Arduino learning?

Start right now with Arduino Step by Step Getting Started

This is our most popular Arduino course, packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up.

Jump to another article in this series.

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