Skip to main content



Raspberry Pi User Guide

Gareth Halfacree, Eben Upton

ISBN: 978-1-118-46449-6 August 2012 264 Pages


Make the most out of the world’s first truly compact computer

It's the size of a credit card, it can be charged like a smartphone, it runs on open-source Linux, and it holds the promise of bringing programming and playing to millions at low cost. And now you can learn how to use this amazing computer from its co-creator, Eben Upton, in Raspberry Pi User Guide. Cowritten with Gareth Halfacree, this guide gets you up and running on Raspberry Pi, whether you're an educator, hacker, hobbyist, or kid. Learn how to connect your Pi to other hardware, install software, write basic programs, and set it up to run robots, multimedia centers, and more.

  • Gets you up and running on Raspberry Pi, a high-tech computer the size of a credit card
  • Helps educators teach students how to program
  • Covers connecting Raspberry Pi to other hardware, such as monitors and keyboards, how to install software, and how to configure Raspberry Pi
  • Shows you how to set up Raspberry Pi as a simple productivity computer, write basic programs in Python, connect to servos and sensors, and drive a robot or multimedia center

Adults, kids, and devoted hardware hackers, now that you've got a Raspberry Pi, get the very most out of it with Raspberry Pi User Guide.

Introduction  1

Programming is fun!  1

A bit of history   3

So what can you do with the Raspberry Pi?  8

Part I: Connecting the Board

CHAPTER 1 Meet the Raspberry Pi    11

ARM vsx86   12

Windows vsLinux  13

Getting Started with the Raspberry Pi  14

Connecting a Display    14

Composite Video    14

HDMI Video  15

DSI Video  16

Connecting Audio     16

Connecting a Keyboard and Mouse  17

Flashing the SD Card    19

Flashing from Linux    20

Flashing from OS X    21

Flashing from Windows   21

Connecting External Storage   22

Connecting the Network    23

Wired Networking    24

Wireless Networking    25

Connecting Power     26

CHAPTER 2 Linux System Administration   27

Linux: An Overview     28

Linux Basics   30

Introducing Debian  30

Using External Storage Devices   34

Creating a New User Account   36

File System Layout  37

Logical Layout  37

Physical Layout  39

Installing and Uninstalling Software  40

Finding Software     41

Installing Software     42

Uninstalling Software    43

Upgrading Software     44

CHAPTER 3 Troubleshooting 45

Keyboard and Mouse Diagnostics   46

Power Diagnostics  47

Display Diagnostics     49

Boot Diagnostics  50

Network Diagnostics     50

The Emergency Kernel     53

CHAPTER 4 Network Configuration    55

Wired Networking  56

Wireless Networking     59

No Encryption     68

WEP Encryption     68

WPA/WPA2 Encryption   69

Connecting to the Wireless Network 69

CHAPTER 5 Partition Management    71

Creating a New Partition    72

Resizing Existing Partitions    76

Automatic Resizing     76

Manual Resizing 77

Moving to a Bigger SD Card    81

Imaging from Linux     82

Imaging from OS X     83

Imaging from Windows    83

CHAPTER 6 Configuring the Raspberry Pi   85

Hardware Settings—config.txt   86

Modifying the Display    87

Boot Options  90

Overclocking the Raspberry Pi   91

Overclocking Settings    92

Overvoltage Settings    93

Disabling L2 Cache     94

Enabling Test Mode    95

Memory Partitioning—start.elf   96

Software Settings—cmdline.txt   97

Part II: Using the Pi as a Media Centre, Productivity Machine and Web Server

CHAPTER 7 The Pi as a Home Theatre PC   103

Playing Music at the Console   104

Dedicated HTPC with Rasbmc   106

Streaming Internet Media   108

Streaming Local Network Media  109

Configuring Rasbmc    111

CHAPTER 8 The Pi as a Productivity Machine  113

Using Cloud-Based Apps    114

Using    117

Image Editing with The Gimp   119

CHAPTER 9 The Pi as a Web Server    123

Installing a LAMP Stack    124

Installing WordPress    128

Part III: Programming and Hacking

CHAPTER 10 An Introduction to Scratch   135

Introducing Scratch    136

Example 1: Hello World    137

Example 2: Animation and Sound  140

Example 3: A Simple Game   143

Robotics and Sensors    149

Sensing with the PicoBoard   149

Robotics with LEGO    150

Further Reading  150

CHAPTER 11 An Introduction to Python   151

Introducing Python    152

Example 1: Hello World    152

Example 2: Comments, Inputs, Variables and Loops   158

Example 3: Gaming with pygame  162

Example 4: Python and Networking  171

Further Reading  178

CHAPTER 12 Hardware Hacking 179

Electronic Equipment    180

Reading Resistor Colour Codes   182

Sourcing Components    184

Online Sources 184

Offline Sources 185

Hobby Specialists    186

The GPIO Port  186

UART Serial Bus     188

I²C Bus   189

SPI Bus   189

Using the GPIO Port in Python  189

Installing the GPIO Python Library  190

GPIO Output: Flashing an LED  192

GPIO Input: Reading a Button  196

Moving Up From the Breadboard  200

A Brief Guide to Soldering   203

CHAPTER 13 Add-on Boards 209

Ciseco Slice of Pi 210

Adafruit Prototyping Pi Plate   214

Fen Logic Gertboard    217

Part IV: Appendixes

APPENDIX A Python Recipes 225

Raspberry Snake (Chapter 11, Example 3) 226

IRC User List (Chapter 11, Example 4)  228

GPIO Input and Output (Chapter 12) 230

APPENDIX B HDMI Display Modes    231

Index 237
Raspberry Pi GPIO Input/Output example
IRC User List
Raspberry Snake
Figure 12-1 (colour version)
Four-band resistor colour decoding table