Using Libraries

To use a library in an Arduino sketch, we need to tell the compiler which library we want to use. There are two ways to do this. The first is to use a #include pre-processor directive at the beginning of our sketch to specify the library’s file name, as follows:

#include <LibraryName.h>

LibraryName.h is the file name of the library that we want to use. In our last project example, we used the line #include <LiquidCrystal.h> to enable those functions that make it easier to use an LCD with our project. Pre-processor directives are instructions to the compiler that tell it to include the functions that we want to use at the time of compiling. They don’t follow the normal syntax of statements and don’t end with semicolons. We mention ...

Get Beginning Arduino Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.