O'Reilly logo

BeagleBone Cookbook by Jason Kridner, Mark A. Yoder

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

Chapter 3. Displays and Other Outputs

Introduction

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

Problem

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

Solution

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.

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 ...

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