C H A P T E R  9

Hardware Libraries

In this chapter we are going to take a bit of a breather on the lengthy code and look at some specific hardware and the appropriate libraries used to make them work. A library is a collection of functions designed to perform specific tasks that make life easier for us. Most of what we have discussed in this book so far, like the functions digitalWrite() or delay(), are a part of the standard Arduino library. These things are so integrated into the way that we write code for the Arduino that we don’t even notice it.

The hardware libraries that we will discuss in this chapter are not a part of the standard, built- in functions because they would take up too much memory. Instead, each library must be added to our sketch when we want to use the extra functionality that it provides. Each library is usually written for a particular type of hardware, so in order to use each of these libraries, we need to have a lot of different hardware available. We have tried to keep our hardware selections to simple and cost-effective choices in order to make trying each of these libraries a possibility. Rather than one or two monstrous projects for the chapter, we will instead look at four smaller examples that put to use the functions described in each section. Beginning with an overview of that library, we will also have an example schematic and illustration, some sample source code, and a breakdown of the main functions in that library. Our code will be kept fairly light so that each mini-project could be used as a building block for something bigger.

This chapter is by no means an exhaustive look at every library available, as we just don’t have enough paper here to do that. Instead, we will work with a few of the common libraries distributed with the Arduino software suitable for our audience. There are many more contributed libraries available to try out that you are encouraged to look into on your own. It is also possible to write custom libraries for specific hardware, but that is a bit more of an advanced topic involving principles of C++—beyond the scope of this book. Let’s begin with an overview of how to use libraries.

What’s needed for this chapter:

  • Arduino Uno
  • 16 × 2 character liquid crystal display HD44780 compatible
  • Hobby servo (Hitec HS-322 or similar)
  • Unipolar or bipolar stepper motor (approximately +5v supply)
  • ULN2003 or SN754410 or similar (as appropriate for the type of stepper motor)
  • Arduino Ethernet Shield (SparkFun or Adafruit SD shield or breakout also okay)
  • LED and appropriate 220-ohm resistor
  • TEMT6000 light sensor or other analog sensor
  • Hookup wires
  • Solderless breadboard
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset