Operation Manual
Chapter 12: Hardware Hacking
In earlier chapters, you learned how the Raspberry Pi can be turned into a flexible platform for running a variety of software.
In this, it’s not alone: any desktop or laptop can run the same software, and in many cases run it far faster than the Pi’s low-
power processor can manage.
The Pi has another trick up its sleeve, though, which places it above and beyond the capabilities of the average PC: its 26-pin
general-purpose input-output (GPIO) port, located on the top-left of the Pi’s printed circuit board.
The GPIO enables the Pi to communicate with other components and circuits, and allows it to act as a controller in a larger
electronic circuit. Through the GPIO port, it’s possible to have the Pi sense temperatures, move servos and talk to other
computing devices using a variety of different protocols including Serial Peripheral Interface (SPI) and Inter-Integrated Circuit
(I²C).
Before you can get begin building circuits to use with the Pi’s GPIO port, however, you’re going to need some additional
equipment.
Electronic Equipment
To start building circuits that can be controlled by the Pi’s GPIO port, you’ll need various components and tools. The following
list provides a sample shopping list for getting started with electronics:
• Breadboard—An electronic breadboard provides a grid of holes spaced at 2.54 mm intervals into which components can
be inserted and removed. Below each grid is a series of electrical contacts, which allow components in the same row to be
connected together without wires. A breadboard is a valuable tool for electronics work, because it allows you to quickly
make mock-up circuits that can be modified without needing to be soldered or desoldered.
• Wires—While a breadboard allows some components to be joined without wiring, you’ll still need wires to connect one
row to another. These are known as jumper wires, and if you’re working on a breadboard, it’s a good idea to get solid-core
wire rather than stranded-core wire. Solid-core wire is easier to insert into the breadboard’s holes compared to stranded. It’s
also helpful to get various colours, so you can colour-code each connection according to its purpose.
• Resistors—The vast majority of electrical circuits make use of components called resistors, and the example projects in this
chapter are no exception. Resistors are measured in ohms, written as the symbol Ω. Always try to have a handful each of a
variety of common values: 2.2 KΩ, 10 KΩ, and 68Ω are good values to start with. Some retailers carry resistor kits, which
include a wide range of useful values.
• Push-Buttons—A very common input component, a push-button completes an electrical circuit when pushed. At the most
basic level, a keyboard is little more than a collection of push-buttons. If you’re designing a circuit to provide a simple input to
the Pi, pick the button labelled momentary switch.
• LEDs—Light-emitting diodes (LEDs) are the most common output device in existence. An LED lights up when voltage is
applied, giving you visual feedback on whether a pin on the Pi’s GPIO port is high or low. When you’re buying LEDs for use
with the Pi, opt for low-power ones. The GPIO port isn’t that powerful, and high-current LEDs—such as bright-white or
bright-blue models—will require an external power supply and an extra component known as a transistor.
Additionally, if you’re planning on making something more permanent once you’ve finished your breadboard prototype (which
you’ll learn about later in this chapter), you’ll also need the following:
• Stripboard—This can be thought of as a single-use breadboard. As with breadboards, holes are arranged in a 2.54 mm
grid. Unlike breadboards, the components need to be soldered into place—after which you’ve got a permanent electronic
circuit.
• Soldering Iron—When you need to connect a component permanently into a circuit, you need to solder it. You don’t have
to spend a fortune on a soldering iron, but if your budget stretches to a temperature-controlled model, it’s a wise investment.
Make sure any soldering iron you buy has a small, pointed tip—chisel-tip irons aren’t suitable for delicate electronic work.
• Solder—Your soldering iron needs solder. Solder is a mixture of conductive metals mixed with a cleaning substance known
as flux. Make sure the solder you buy is suitable for electronics work—thick, plumbing solder is cheap but may damage
delicate circuits, because it requires too much heat to melt.
• Stand and Sponge—It’s important to have somewhere to put the hot soldering iron when it’s not in use, and a way of
cleaning the tip of the iron while you’re using it. Some soldering irons come with a stand with a built-in cleaning sponge—if