Using Arduino Object Libraries
Many of the Arduino sketches rely on libraries. Libraries extend the functionality of the Arduino, and are an integral part of the this and any microcontroller development system.
A library is composed of one or more files; all of the files are contained in a folder, to make it easier to manage them. Library folders are then placed within the file structure of the Arduino integrated development environment (IDE), so that the software can find and use them.
Some libraries are included with the Arduino IDE (standard), and others must be manually added in order to compile and upload the sketch (contributed).
Standard Objects
Standard libraries are those that are included with the Arduino IDE software. To use one, simply add a reference to the library to the top of the sketch using the #include statement, such as
#include <servo.h>
This adds the Servo library to the sketch.
Contributed Objects
Contributed libraries are those that are not provided with the Arduino IDE software, and must be manually added. Contributed libraries may be added in either of two ways:
- Global – Place the library inside the main libraries folder of the Arduino sketch directory, so that it is available to all sketches. This is the most common method. See Installing Additional Arduino Libraries for more information on locating the Arduino sketch library on your computer and adding more libraries to it.
- Local – Place the library inside the same folder as the sketch. The library is available to only the current sketch.
Most contributed libraries are provided in zip or other self-contained archive files. You must unpack (decompress) the zip file before you can use it.
When a contributed library is required to compile a KickStart example, either the library files are included with the example, or a link is provided so you can download the library directly from its source.
Important! Be sure to restart the Arduino IDE software after adding a new library.
See Also
Arduino Libraries for additional general information on using Arduino libraries.
Arduino libraries are also sometimes referred to as object libraries. Objects are special programming elements that gives an Arduino sketch extra flexibility, and form the basis of object oriented programming.
- Copyright: Creative Commons 3.0 SA license