O'Reilly logo

Arduino Sketches: Tools and Techniques for Programming Wizardry by James A. Langbridge

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER24

Importing Third-Party Libraries

This chapter requires the following:

  • Arduino Uno
  • Adafruit Si1145 breakout board

As you have seen throughout this book, the Arduino libraries add an impressive amount of functionality to the platform. They facilitate the use of a large number of electronic components and breakout boards. In some cases, using a shield is as simple as selecting the correct library, but this isn't always the case. The Arduino ecosystem has grown immensely over the years; it has been used for an unbelievably large amount of projects. Not all use “standard” components; some need more specific hardware.

When you import a library, the Arduino has access to more functionality. For example, the SD library enables you to easily write to large storage formats with an Arduino, something that would otherwise be difficult to do. This is done by adding functions, pieces of code that help you talk to hardware, or performing software calculations and actions. Libraries facilitate this by importing these functions and making them available to the sketch. Sketches can, of course, add existing standard Arduino libraries, but they can also add libraries written by third parties.

Libraries

So what exactly is a library? Sketches are written in a form of C, and a library is simply an extension, written in either C or C++. When you create a function in your sketch, you can call it inside the same sketch. A library has a collection of functions that can be reused in multiple sketches. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required