Chapter 3. Displays and Other Outputs


In this chapter, you will learn how to control physical hardware via BeagleBone Black’s general-purpose input/output (GPIO) pins. The Bone has some 65 GPIO pins that are brought out on two 46-pin headers, called P8 and P9, as shown in Figure 3-1.

Headers P8 and P9
Figure 3-1. The P8 and P9 GPIO headers

The purpose of this chapter is to give simple examples that show how to use various methods of output. Most solutions require a breadboard and some jumper wires.

All these examples assume you know how to edit a file (Editing Code Using the Cloud9 IDE) and run it, either within Cloud9 or from the command line (Getting to the Command Shell via ssh).

Toggling an On-Board LED


You want to know how to flash the four LEDs that are next to the Ethernet port on the Bone.


Locate the four on-board LEDs shown in Figure 3-2. They are labeled USR0 - USR3, but we’ll refer to them as the USER LEDs.

Figure 3-2. The four USER LEDs

Place the code shown in Example 3-1 in a file called internLED.js. You can do this using Cloud9 to edit files (as shown in Editing Code Using the Cloud9 IDE) or with a more traditional editor (as shown in Editing a Text File from the GNU/Linux Command Shell).

Example 3-1. Using an internal LED (internLED.js)
#!/usr/bin/env node
var b = require ...

Get BeagleBone Cookbook now with O’Reilly online learning.

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