This is the chapter web page to support the content in Chapter 10 of the book: Exploring Raspberry Pi – Interfacing to the Real World with Embedded Linux. The summary introduction to the chapter is as follows:

In this chapter, you learn how to build on your knowledge of general-purpose input/output (GPIO) and bus interfacing. In particular, you can combine hardware and software to provide the Raspberry Pi (RPi) with the ability to interact with its physical environment in the following three ways: First, by controlling actuators such as motors, the RPi can affect its environment, which is very important for applications such as robotics and home automation. Second, the RPi can gather information about its physical environment by communicating with sensors. Third, by interfacing to display modules, the RPi can present information. This chapter explains how each of these interactions can be performed. Physical interaction hardware and software provides you with the capability to build advanced projects (for example, to build a robotic platform that can sense and interact with its environment). The chapter finishes with a discussion on how you can create your own C/C++ code libraries and utilize them to build highly scalable projects.

After completing this chapter, you should hopefully be able to do the following:

  • Interface to actuators, such as DC motors, stepper motors, and relays.
  • Condition a sensor signal so that it can be interfaced to an SPI ADC, which is attached to the RPi.
  • Correctly interface analog sensors such as distance sensors, temperature sensors, and accelerometers to the RPi.
  • Interface to low-cost display modules such as seven-segment displays, character LCD displays, and OLED dot-matrix displays.
  • Utilize makefiles and CMake to build libraries of code that can be used to build highly scalable C/C++ projects.

Digital Media Resources

Here are some important images that may be useful in a higher-resolution color format. There are other images from the same chapter available at the bottom of this page.

The Simple Motor Controller

Character LCD Displays from the Chapter

OLCD Displays from the Chapter

Driving Stepper Motors with the EasyDriver Board

This video examines how we can drive stepper motors using C++ within Embedded Linux using the open source hardware EasyDriver board. The video begins by describing stepper motors and the effects of micro-stepping. It then discusses the EasyDriver Board (V4.4) and all of the available inputs and outputs. The board uses the Allegro A3967 which allows for full, half-, quarter and one eight micro-stepping. The video then describes C++ code that uses the GPIOs on an embedded Linux device to wrap the EasyDriver with a C++ class.

Source Code Examples

All of the source code that is described in this book is available in a public GitHub repository: Derek Molloy Exploring Raspberry Pi repository.

You can clone this repository on a Linux desktop computer or your Raspberry Pi using the command:

The code for this chapter can be accessed in the chp10 folder of the cloned repository. Some formatted code is provided here for your convenience.

Some Other High-Resolution Figures from this Chapter


None for the moment