Raspberry Pi® For Dummies®

Visit to view this book's cheat sheet.

Table of Contents


About Raspberry Pi For Dummies

Why You Need This Book

Foolish Assumptions

How This Book Is Organized

Icons Used in This Book

Visit the Book’s Website

Part I: Getting Started with the Raspberry Pi

Chapter 1: Introducing the Raspberry Pi

Getting Familiar with the Raspberry Pi

Figuring Out What You Can Do with a Raspberry Pi

Determining Its Limitations

Getting Your Hands on a Raspberry Pi

Deciding What Else You Need

Chapter 2: Downloading the Operating System

Introducing Linux

Determining Which Distribution to Use

Using RISC OS on the Raspberry Pi

Downloading a Linux Distribution

Unzipping Your Linux Distribution

Flashing Your SD Card

Flashing an SD card in Windows

Flashing an SD card on a Mac

Flashing an SD card using Linux

Chapter 3: Connecting Your Raspberry Pi

Inserting the SD Card

Connecting a Monitor or TV

Connecting an HDMI or DVI display

Connecting a television using composite video

Connecting a USB Hub

Connecting a Keyboard and Mouse

Connecting Audio

Connecting to Your Router

Connecting the Power and Turning on the Raspberry Pi

Using Raspi-config to Set Up Your Raspberry Pi

Logging In

Creating a Protective Case for Your Raspberry Pi

Part II: Getting Started with Linux

Chapter 4: Using the Desktop Environment

Starting the Desktop Environment

Navigating the Desktop Environment

Using the icons on the desktop

Using the Programs menu

Using multiple desktops

Resizing and closing your program windows

Using the Task Manager

Using External Storage Devices in the Desktop Environment

Using the File Manager

Navigating the file manager

Copying and moving files and folders

Selecting multiple files and folders

Creating new folders and blank files

Changing how files are displayed

Opening a folder as root or in the terminal

Browsing the Web

Using Midori to browse the web

Searching for and within web pages

Using tabbed browsing

Adding and using bookmarks

Zooming the page and opening it full screen

Protecting your privacy

Using the Image Viewer

Using the Leafpad Text Editor

Customizing Your Desktop

Logging Out from LXDE

Chapter 5: Using the Linux Shell

Understanding the Prompt

Exploring Your Linux System

Listing files and directories

Changing directories

Checking file types

Changing to the parent directory

Understanding the directory tree

Using relative and absolute paths

Investigating more advanced listing options

Understanding the Long Listing Format and Permissions

Slowing Down the Listing and Reading Files with the Less Command

Speeding Up Entering Commands

Using Redirection to Create Files in Linux

Top Tips for Naming Your Files in Linux

Creating Directories

Deleting Files in Linux

Using Wildcards to Select Multiple Files in Linux

Removing Directories

Copying and Renaming Files

Installing and Managing Software on Your Raspberry Pi

Updating the cache

Finding the package name

Installing software

Running software

Upgrading the software on your Raspberry Pi

Removing software and freeing up space

Finding out what’s installed on your Raspberry Pi

Managing User Accounts on Your Raspberry Pi

Learning More About Linux Commands

Customizing Your Shell with Your Own Linux Commands

Part III: Using the Raspberry Pi for Both Work and Play

Chapter 6: Being Productive with the Raspberry Pi

Installing LibreOffice on Your Raspberry Pi

Starting LibreOffice on the Raspberry Pi

Saving Your Work

Writing Letters in LibreOffice Writer

Managing Your Budget in LibreOffice Calc

Creating Presentations in LibreOffice Impress

Creating a Party Invitation with LibreOffice Draw

Chapter 7: Editing Photos on the Raspberry Pi with GIMP

Installing and Starting GIMP

Understanding the GIMP Screen Layout

Resizing an Image in GIMP

Cropping Your Photo

Rotating and Flipping Your Photo

Adjusting the Colors

Fixing Imperfections

Converting Images Between Different Formats

Finding Out More about GIMP

Chapter 8: Building Your First Website with the Raspberry Pi

Understanding What a Website Is

Discovering How to Write a Web Page

Organizing Your Files

Creating Your First Web Page

Your first HTML code snippet

Structuring an HTML document

Formatting Your HTML Content

Adding additional headings

Adding images to your web page

Adding links in your web content

Formatting lists

Additional formatting tags you can use

Validating Your HTML

Using CSS to Change Your Page’s Appearance

Adding a style sheet to your web page

Adding a touch of color

Formatting your text

Styling lists

Adding borders to your content

Adding spacing around and between page elements

Applying Styles to More Specific Parts of the Page

Creating a Navigation Bar from a List

Adding the Finishing Touches

Publishing Your Web Page on the Internet

Taking It Further

Chapter 9: Playing Audio and Video on the Raspberry Pi

Setting Up Raspbmc

Navigating Raspbmc

Adding Media

Adding a USB device

Adding networked media

Using streaming media

Playing Music

Playing Videos

Viewing Photos

Changing the Settings in Raspbmc

Using a Remote Control

Playing Music in the Desktop Environment

Part IV: Programming the Raspberry Pi

Chapter 10: Introducing Programming with Scratch

Understanding What Programming Is

Starting Scratch

Understanding the Scratch Screen Layout

Positioning and Resizing Your Sprite

Making Your Sprite Move

Using directions to move your sprite

Using grid coordinates to move and position your sprite

Showing sprite information on the Stage

Changing Your Sprite’s Appearance

Using costumes

Using speech and thought bubbles

Using graphic effects

Resizing your sprite

Changing your sprite’s visibility

Adding Sounds and Music

Creating Scripts

Using the Wait Block to Slow Down Your Sprite

Saving Your Work

Chapter 11: Programming an Arcade Game Using Scratch

Starting a New Scratch Project and Deleting Sprites

Changing the Background

Adding Sprites to Your Game

Drawing Sprites in Scratch

Naming Your Sprites

Controlling When Scripts Run

Using the green flag to start scripts

Using the Forever Control block

Enabling keyboard control of a sprite

Enabling a sprite to control another sprite

Using Random Numbers

Detecting When a Sprite Hits Another Sprite

Introducing Variables

Making Sprites Move Automatically

Fixing the Final Bug

Adding Scripts to the Stage

Duplicating Sprites

Playing Your Game

Adapting the Game’s Speed

Taking It Further with Scratch

Chapter 12: Writing Programs in Python

Starting Python

Entering Your First Python Commands

Using the Shell to Calculate Sums

Creating the Times Tables Program

Creating and running your first Python program

Using variables

Accepting user input

Printing words, variables, and numbers together

Using for loops to repeat

Creating the Chatbot Program

Introducing lists

Using lists to make a random chat program

Adding a while loop

Using a loop to force a reply from the player

Using dictionaries

Creating your own functions

Creating the dictionary look-up function

Creating the main conversation loop

Final thoughts on Chatbot

The final Chatbot program

Chapter 13: Creating a Game with Python and Pygame

Installing and Updating Pygame

Importing Pygame

Setting Up the Game Window

Using Colors in Pygame

Drawing with Pygame

Creating the Game Map

Drawing the Bricks

Positioning the Bat

Positioning the Ball

Displaying the End Game Messages

Checking for a Win

Setting Up the Timings

Making the Bat Move

Making the Ball Move

Adapting the Game

Part V: Exploring Electronics with the Raspberry Pi

Chapter 14: Understanding Circuits and Soldering

Discovering What a Circuit Is

Understanding the nature of electricity

Determining how a component needs to be treated

Testing circuits with simulators

Getting Familiar with the GPIO

Putting the general purpose in GPIO

Understanding what GPIOs do

Putting an output pin to practical use

Using GPIOs as inputs

Learning which end is hot: Getting to grips with a soldering iron

Making a soldered joint

Looking at Ready-Made Add-On Boards

The Gert board

Pi Face

Other boards

Chapter 15: Making Your First Project with the Raspberry Pi

Getting Started with the Blastoff Project

Getting at the GPIO Pins

Being aware of Raspberry Pi board revisions

Making the connection

Making a Breakout Board

Creating the cable

Wiring the cable

Testing the breakout board

Controlling the GPIO pins

Floating GPIO pins

Getting a better display

Creating the Blastoff Game

Making the box

Wiring up the Blastoff game

Testing the hardware

Writing the software

The game logic

Creating the sounds

Customizing the Blastoff game

Chapter 16: Putting the Raspberry Pi in Control

Using GPIO Pins as Outputs

Preparing to Build the Copycat Game

Choosing an LED

Creating the Copycat Game

Customizing the Game

Making a Better Game

Putting It All Together

Chapter 17 : The Raspberry Pi in an Analog World

Exploring the Difference: Analog versus Digital

Taking small steps

Reading small steps

Investigating Converter Chips

Building the Raspberry Ripple

The chip at the heart of the Ripple

Putting the chip into a circuit

Wiring it up

Installing the drivers

Using the Raspberry Ripple

Testing the analog inputs

Testing the analog output

Making a Curve Tracer

Making a Pot-a-Sketch

Making Real Meters

Making a Steve Reich Machine

Taking the Temperature

Part VI: The Part of Tens

Chapter 18: Ten Great Software Packages for the Raspberry Pi

Penguins Puzzle



XInvaders 3D



Tux Paint


Beneath a Steel Sky


Chapter 19: Ten Inspiring Projects for the Raspberry Pi

One-Button Audiobook Player

Raspberry Pi Synthesizer

Bird Feeder Webcam

Scratch Games

Weather Station


Baby Monitor

Remote-Controlled Cars

A Talking Boat

Home Automation

Appendix A: Troubleshooting and Configuring the Raspberry Pi

Using Nano to edit config.txt

Troubleshooting screen display issues

Adjusting the screen display

Exploring more advanced settings

Appendix B: The GPIO on the Raspberry Pi

Cheat Sheet


About the Authors

Sean McManus is an expert technology and business author. His other books include Microsoft Office for the Older and Wiser, Social Networking for the Older and Wiser, Web Design in Easy Steps, and iPad for the Older and Wiser. His tutorials and articles have appeared in magazines including Internet Magazine, Internet Works, Business 2.0, Making Music, and Personal Computer World. His personal website is at

Mike Cook has been making electronic things since he was at school. Former Lecturer in Physics at Manchester Metropolitan University, he wrote more than three hundred computing and electronics articles in the pages of computer magazines for 20 years starting in the 1980s. Leaving the University after 21 years when the Physics department closed down, he got a series of proper jobs where he designed digital TV set top boxes and access control systems. Now retired and freelancing, he spends his days surrounded by wires, patrolling the forums as Grumpy Mike.


Thank you to my wife, Karen, for all her support throughout this project. —Sean

To my wife, Wendy, who always acts delighted whenever I show her yet another blinking LED. And also to the late Leicester Taylor, World War II radar researcher and inspirational supervisor of my post-graduate research at the University of Salford. —Mike

Authors’ Acknowledgments

Thank you to my co-author, Mike, for bringing his electronics expertise and fantastic project ideas. Thank you to Craig Smith for commissioning us to write this book, to Linda Morris for her editing support, and to Paul Hallett, our technical editor. Thanks also to Lorna Mein and Natasha Lee in marketing, and to the . . . For Dummies team for making it all happen.

Many people helped with research or permissions requests, including Karen McManus, Leo McHugh, Mark Turner, Peter Sayer, Bill Kendrick, Simon Cox, Jon Williamson, Paul Beech, Peter de Rivaz, Michał Męciński, Ruairi Glynn, Stephen Revill, and Lawrence James.

We wouldn’t have a book to write if it weren’t for the wonderful work of the Raspberry Pi Foundation, the manufacturers who took a gamble on it, and the many thousands of people who have contributed to the Raspberry Pi’s software. —Sean

I would like to thank Sean McManus for inviting me to contribute to this book and the staff at Wiley for making the process of producing this book as painless as possible. —Mike

Publisher’s Acknowledgments

We’re proud of this book; please send us your comments at For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.

Some of the people who helped bring this book to market include the following:

Acquisitions and Editorial

Project Editor: Linda Morris

Acquisitions Editor: Craig Smith

Copy Editor: Linda Morris

Technical Editor: Paul Hallett

Editorial Manager: Jodi Jensen

Editorial Assistant: Anne Sullivan

Sr. Editorial Assistant: Cherie Case

Cover Photo: © Dr. Andrew Robinson

Composition Services

Sr. Project Coordinator: Kristie Rees

Layout and Graphics: Carrie A. Cesavice, Jennifer Creasey, Joyce Haughey

Proofreader: Linda Seifert

Indexer: Potomac Indexing, LLC

Publishing and Editorial for Technology Dummies

Richard Swadley, Vice President and Executive Group Publisher

Andy Cummings, Vice President and Publisher

Mary Bednarek, Executive Acquisitions Director

Mary C. Corder, Editorial Director

Publishing for Consumer Dummies

Kathleen Nebenhaus, Vice President and Executive Publisher

Composition Services

Debbie Stailey, Director of Composition Services


In recent years, computer education has focused largely on office skills, and not on understanding how computers work, or how you can use them to create new programs and inventions. The Raspberry Pi redresses the balance. It can be used for games, music, photo editing, and word processing, like any computer. But it can do so much more, providing a gateway into programming, electronics, and the mysterious world of Linux, the technically powerful (and free) rival to Windows and Mac OS.

Although the Raspberry Pi presents new opportunities to everyone, it can also be a daunting prospect. It comes as a bare circuit board, so to do anything with it, you’ll need to add an operating system on an SD card and connect it up to a screen, mouse, and keyboard. To get started, you need to learn a few basics of Linux, or at least get acquainted with LXDE, the graphical desktop. You might be a geek who relishes learning new technologies, or you might be someone who wants a new family computer to use with the children. In either case, Raspberry Pi For Dummies helps you to get started with your Raspberry Pi and teaches you about some of the many fun and inspiring things you can do with it.

About Raspberry Pi For Dummies

Raspberry Pi For Dummies provides a concise and clear introduction to the terminology, technology, and techniques that you need to get the most from your Pi. With the book as your guide, you’ll learn how to

check.png Connect up your Raspberry Pi.

check.png Change its settings so it works optimally for you.

check.png Discover and install great free software you can use on your Raspberry Pi.

check.png Use the desktop environment to run programs, manage your files, surf the web, and view your photos.

check.png Use the Linux command line to manage your Raspberry Pi and its files.

check.png Use the Raspberry Pi as a productivity tool.

check.png Edit photos.

check.png Play music and video.

check.png Build and publish your first website using the tools on the Raspberry Pi and free tools you can download.

check.png Create animations and arcade games with the child-friendly Scratch programming language.

check.png Write your own games and other programs using the Python programming language.

check.png Get started with electronics, from an introduction to soldering, to the design and creation of sophisticated electronic games, controlled by the Raspberry Pi.

Why You Need This Book

After you shake the Raspberry Pi out of the little electrostatic bag it comes in, what next?

This book answers that question. It enables you to get your Raspberry Pi up and running and also introduces you to some of the great things you can do with it, through satisfying practical projects. With this book as your companion, you can build websites, write games, and create your own electronic gadgets, all without any prior knowledge.

The Raspberry Pi is most likely a bit different compared to other computers you’ve used, so this book also helps you to do some of the things on your Pi that you expect of every computer, such as playing music and editing documents.

You can learn a lot of this through trial and error, of course, but that can be a frustrating way to spend your time. Using this book as a reference, you can more quickly start using your Raspberry Pi, whatever you plan to do with it.

Foolish Assumptions

Raspberry Pi For Dummies is written for beginners, by which we mean people who have never used a similar computer before. However, we do have to make a few assumptions in writing this book because we wouldn’t have enough space for all the cool projects if we had to start by explaining what a mouse is! Here are our assumptions:

check.png You are familiar with other computers, such as Windows or Apple computers. In particular, we assume that you’re familiar with using windows, icons, and the keyboard and mouse, and that you know the basics of using your computer for things like the Internet or writing letters.

check.png The Raspberry Pi is not your only computer. At times, you’ll need to have access to another computer, for example to create your SD card for the Pi (see Chapter 2). When it comes to networking, we assume you already have a router set up with an Internet connection and a spare port that you can plug the Raspberry Pi into.

check.png The Raspberry Pi is your first Linux-based computer. If you’re a Linux ninja, this book still gives you a solid reference on the Raspberry Pi and the version of Linux it uses, but no prior Linux knowledge is required.

check.png You share our excitement at the world of possibilities that the Raspberry Pi can open up to you!

Other than those assumptions, we hope this book is approachable for everyone. The Raspberry Pi is being adopted in classrooms and youth groups, and this book is a useful resource for teachers and students. The Raspberry Pi is also finding its way into many homes, where people of all ages (from children to adult) are using it for education and entertainment.

How This Book Is Organized

This book is organized into six parts:

check.png Part I shows you how to set up your Raspberry Pi, including guidance on what else you need; how you download the Raspberry Pi’s operating system software and copy it to an SD card; and how you connect everything up. You’ll learn how to use the configuration software and log in to your Raspberry Pi.

check.png Part II gets you up and running with Linux, the operating system that runs on the Raspberry Pi. You’ll learn about the desktop environment, which you can use to run programs, manage your files, browse the web, and view your images. Many Raspberry Pi users spend most of their time in the desktop environment, but others want to dig deeper into Linux, learning how to enter text commands to manage the computer and its files. The book also shows you how to do this, so you can exploit the full power of Linux.

check.png Part III is all about using your Raspberry Pi for work and play. You can’t use Windows or Mac OS software on your Raspberry Pi, so you need to find and install some new programs for work, photo-editing, and playing music and video. You also learn how to build your first website, using HTML and CSS, the languages that underpin every website in the world.

check.png Part IV teaches you how to write your own programs for the Raspberry Pi, using the two programming languages that come with the operating system. Scratch is highly visual and ideal for making games and animations. After we introduce you to the concepts of Scratch, we show you how you can bring them together to make a shoot-‘em-up game. After that, you learn Python, a more powerful programing language that comes with the Raspberry Pi. We’ll show you how to create a basic Chatbot that analyzes what you type in and gives intelligent responses (sometimes, at least). After you’ve mastered the basics of Python, we show you how to write an arcade game using Pygame.

check.png Part V introduces you to some electronics projects you can undertake with your Raspberry Pi. You learn the basics of electronics theory, how to use a soldering iron, and how the Raspberry Pi can be connected to your own electronics circuits. This section builds on your knowledge of Python to show you how to make two electronic games controlled by the Raspberry Pi, Marble Slalom, and Copycat. The last chapter in this part shows you how to make an analog-to-digital converter that you can use for a wide range of your own electronics projects.

check.png Part VI is the Part of Tens, a unique feature of the For Dummies series. This part contains concise guides to great software you can install on your Raspberry Pi and inspiring projects you can make with it.

check.png Finally, Appendix A covers troubleshooting and more advanced configuration options of your Raspberry Pi. This gives you solutions for the most common problems people experience, and some guidance on directly editing the configuration files. You might not need this chapter, but it’s good to know it’s there if things go wrong! Appendix B provides a reference to the GPIO that you can consult when connecting your own electronics projects to the Raspberry Pi.

It’s up to you how you read this book. It’s been organized to take you on a journey from acquiring and setting up your Raspberry Pi, through learning the software that comes with it, to writing your own programs, and finally creating your own electronics projects. Some chapters build on knowledge gained in earlier chapters, especially the sections on Scratch, Python, and all of Part V.

We understand, though, that some projects or topics might interest you more than others, and you might need help in some areas right now. When a chapter assumes knowledge from elsewhere, we’ve included cross-references to help you quickly find what you might have missed. We’ve also included some signposts to future chapters too, so you can skip ahead to a later chapter if it provides the quickest answer for you.

Icons Used in This Book

If you’ve read other For Dummies books, you know that they use icons in the margin to call attention to particularly important or useful ideas in the text. In this book, we use four such icons:

tip.eps The Tip icon highlights expert shortcuts or simple ideas that can make life easier for you.

technicalstuff.eps Arguably, the whole book is technical stuff, but this icon highlights something that’s particularly technical. We’ve tried to avoid unnecessary jargon and complexity, but some background information can give you a better understanding of what you’re doing, and sometimes we do need to get quite techy, given the sophistication of the projects we’re doing. Sections highlighted with this icon might be worth re-reading to make sure you understand, or you might decide that you don’t need to know that much detail. It’s up to you!

remember.eps Although we’d like to think that reading this book is an unforgettable experience, we’ve highlighted some points that you might want to particularly commit to memory. They’re either important take-aways, or they are fundamental to the project you’re working on.

warning_bomb.eps As you would on the road, slow down when you see a warning sign. It highlights an area where things could go wrong.

Visit the Book’s Website

You can find the dedicated website for this book at You can download the files used in the website design, programming, and electronics projects there. That saves you having to retype them, and also gives you a sound base you can build on for your own projects.

Occasionally, we have updates to our technology books. If this book does have technical updates, they will be posted at

Both of us maintain our own personal websites too, which contain some additional information on the Raspberry Pi. Mike’s is at and Sean’s is at

Part I

Getting Started with the Raspberry Pi


pt_webextra_bw.TIF Visit for great Dummies content online.

In this part . . .

check.png Get to know the Raspberry Pi, and what other equipment you will need to be able to use it.

check.png Download the Linux operating system and flash it to an SD card.

check.png Connect your Raspberry Pi to the power, USB hub, keyboard, mouse, and screen.

check.png Use Raspi-config to change the settings on your Raspberry Pi.

Chapter 1

Introducing the Raspberry Pi

In This Chapter

arrow Getting familiar with the Raspberry Pi

arrow Figuring out what you can do with a Raspberry Pi

arrow Determining its limitations

arrow Getting your hands on a Raspberry Pi

arrow Deciding what else you need

The Raspberry Pi is perhaps the most inspiring computer available today. Although most of the computing devices we use (including phones, tablets, and games consoles) are designed to stop us from tinkering with them, the Raspberry Pi is exactly the opposite. From the moment you see its shiny green circuit board, it invites you to prod it, play with it, and create with it. It comes with the tools you need to start making your own software (or programming), and you can connect your own electronic inventions to it. It’s cheap enough that if you break it, it’s not going to break the bank, so you can experiment with confidence.

Lots of people are fired up about its potential, and they’re discovering exciting new ways to use it together. Dave Akerman ( and friends attached one to a weather balloon and sent it nearly 40 kilometers above the earth to take pictures of earth from near space using a webcam.

Professor Simon Cox and his team at the University of Southampton connected 64 Raspberry Pi boards to build an experimental supercomputer, held together with Lego bricks. In the supercomputer (see Figure 1-1), the Raspberry Pis work together to solve a single problem. The project has been able to cut the cost of a supercomputer from millions of dollars to thousands or even hundreds of dollars, making supercomputing much more accessible to schools and students.

The Pi is also being used at the frontier of exploration. The FishPi project ( aims to create a vessel that can navigate across the Atlantic unmanned and take environmental measurements along the way, communicating with base by satellite. London Zoo is looking at using the Raspberry Pi in a device to detect and photograph animals in their natural habitats, called EyesPi.


Courtesy of Simon Cox and Glenn Harris, University of Southampton

Figure 1-1: Two of the Raspberry Pi boards used in the University of Southampton’s supercomputer, with the rest of the supercomputer in the background.

Although those projects are grabbing headlines, another story is less visible but more important: the thousands of people of all ages who are taking their first steps in computer science thanks to the Raspberry Pi.

Both of the authors of this book used computers in the 1980s, when the notion of a home computer first became a reality. Back then, computers were less friendly than they are today. When you switched them on, you were faced with a flashing cursor and had to type something in to get it to do anything. As a result, though, a whole generation grew up knowing at least a little bit about how to give the computer commands, and how to create programs for it. As computers became friendlier, and we started to use mice and windows, we didn’t need those skills any more, and we lost touch with them.

Eben Upton, designer of the Raspberry Pi, noticed the slide in skill levels when he was working at Cambridge University’s Computer Laboratory in 2006. Students applying to study computer science started to have less experience of programming than students of the past did. Upton and his university colleagues hatched the idea of creating a computer that would come with all the tools needed to program it, and would sell for a target price of $25. It had to be able to do other interesting things too so that people were drawn to use it, and had to be robust enough to survive being pushed in and out of school bags hundreds of times.

That idea started a six-year journey that led to the Raspberry Pi you probably have on your desk you as you read this book. It was released in February 2012, and sold half a million units by the end of the quarter. Early in 2013, it reached the milestone of one million sales.

Getting Familiar with the Raspberry Pi

When your Raspberry Pi arrives, you’ll see it’s a circuit board, about the size of a credit card, with components and sockets stuck on it, as shown in Figure 1-2. In an age when most computing devices are sleek and shiny boxes, the spiky Pi, with tiny codes printed in white all over it, seems alien. It’s a big part of its appeal, though: most of the cases you can buy for the Raspberry Pi are transparent because people love the look of it.


Figure 1-2: Up close with the Raspberry Pi.

There are two versions of the Raspberry Pi: the Model B (which was released first) and the Model A. The differences between the two are that the Model B has two USB sockets (whereas the Model A only has one), the Model B has an Ethernet socket, and editions of the Model B released after October 2012 contain twice the memory (512MB, compared to 256MB on the Model A and the first batches of the Model B). The Model A sells for $25, whereas the Model B sells for around $35.

technicalstuff.eps The Raspberry Pi was made possible in part by the advances in mobile computer chips that have happened in recent years. At its heart is a Broadcom BCM2835 chip that contains an ARM central processing unit (CPU) and a Videocore 4 graphics processing unit (GPU). The CPU and GPU share the memory between them. The GPU is powerful enough to be able to handle Blu-ray quality video playback.

Instead of running Windows or Mac OS, the Raspberry Pi uses an operating system called Linux. It’s a leading example of open source, a completely different philosophy to the commercial software industry. Instead of being created within the heavily guarded walls of a company, with its design treated as a trade secret, Linux is built by companies and expert volunteers working together. Anyone is free to inspect and modify the source code (a bit like the recipe) that makes it work. You don’t have to pay to use Linux, and you’re allowed to share it with other people too.

Unless you already use Linux, you won’t be able to run the software you have on your other computers on your Raspberry Pi, but a lot of software for Linux is free of charge.

Figuring Out What You Can Do with a Raspberry Pi

The Raspberry Pi is a fully featured computer, and you can do almost anything with it that you can do with a desktop computer.

When you switch it on, it has a text prompt (see Chapter 5), but you can use a graphical windows desktop to start and manage programs. You can use it for browsing the Internet (see Chapter 4), word processing and spreadsheets (see Chapter 6), or for editing photos (see Chapter 7). You can use it for playing back music or video (see Chapter 9), or for playing games. You can use the built-in software to build a website (see Chapter 8). It’s the perfect tool for homework, but it’s also a useful computer for writing letters, managing your accounts, and paying bills online.

The Raspberry Pi is at its best, however, when it’s being used to learn how computers work, and how you can create your own programs or electronics projects using them. It comes with Scratch (see Chapter 10), which enables people of all ages to create their own animations and games, while learning some of the core concepts of computer programming along the way.

It also comes with Python (see Chapter 12), a professional programming language used by YouTube, Google, and Industrial Light & Magic (the special effects gurus for the Star Wars films), among many others.

It has a General Purpose Input/Output (GPIO) port on it that you can use to connect up your own circuits to the Raspberry Pi, so you can use your Raspberry Pi to control other devices and to receive and interpret signals from them. In Part V, we show you how to build some electronic games controlled by the Raspberry Pi.

Determining Its Limitations

For something that costs so little, the Raspberry Pi is amazingly powerful, but it does have some limitations. Although you probably use it as a desktop computer, its power is closer to a mobile device (like a tablet) than a modern desktop PC.

By way of example, the Raspberry Pi Foundation says the Pi’s overall performance is comparable with a PC using a 300 MHz Pentium 2 processor, which you might have bought in the mid to late nineties, except that the Raspberry Pi has much better graphics. The memory of the Raspberry Pi is more limited than you’re probably used to, with just 512MB or 256MB available. You can’t expand that with extra memory in the way you can a desktop PC.

The graphics capabilities lag behind today’s market somewhat too: The Raspberry Pi Foundation says the Pi’s graphics are roughly the same as the original Xbox games console, which was released 10 years ago.

Both the Pentium 2 PC and the original Xbox were fine machines, of course, for their time. They’re just not as snappy as we’re used to, and that’s where you might experience some problems. You might find that the Pi can’t keep up with the demands of some modern software and that some programs don’t run fast enough to be useful on it. However, it’s easy to find programs, try them, and remove them if they’re no good (see Chapter 5), and plenty of programs for work and play run well on the Raspberry Pi (see Chapter 18).

If you already have another computer, the Raspberry Pi is unlikely to usurp it as your main machine. But the Pi gives you the freedom to try lots of things you probably wouldn’t dare to try, or wouldn’t know how to try, with your main PC.

Getting Your Hands on a Raspberry Pi

The Raspberry Pi was created by the Raspberry Pi Foundation, a charity registered in the UK. The charity’s six trustees funded the manufacture of the first large batch themselves, but it sold out rapidly so it quickly became clear that they needed something that would scale better.

The Foundation now licenses the design of the Raspberry Pi to RS Components ( and Premier Farnell, which uses the brand name Element 14 ( Both companies fund and manage the manufacture of the Raspberry Pi, market and sell it, and look after their customers. They accept orders through their websites and are able to offer a number of the accessories you might also need.

It’s possible that more companies will license the design of the Pi in the future, so check the Raspberry Pi Foundation’s website at for current links to stores that sell the Pi.

Second-hand Raspberry Pis can be bought on eBay (, but we would recommend getting a new one so you benefit from the customer support available, and have the peace of mind that it hasn’t been damaged by the previous owner.

Deciding What Else You Need

The creators of Raspberry Pi have stripped costs to the bone to enable you to own a fully featured computer for about $25–$35, so you’ll need to scavenge or buy a few other bits and pieces. I say “scavenge” because the things you need are exactly the kind of things many people have lying around their house or garage already, or can easily pick up from friends or neighbors. In particular, if you’re using a Raspberry Pi as your second computer, you probably have most of the peripherals you need. That said, you might find they’re not fully compatible with the Raspberry Pi and you need to buy replacements to use with the Pi.

Here’s a checklist of what else you might need:

check.png Monitor: The Raspberry Pi has a high definition video feed and uses an HDMI (high definition multimedia interface) connection for it. If your monitor has an HDMI socket, you can connect the Raspberry Pi directly to it. If your monitor does not support HDMI, it probably has a DVI socket, and you can get a simple and cheap converter that enables you to connect an HDMI cable to it. Older VGA (video graphics array) monitors aren’t officially supported by the Raspberry Pi Foundation, but devices are available to convert the HDMI signal into a VGA one. If you’re thinking of buying a converter, check online to see whether it works with the Raspberry Pi first. A lot of cheap cables are just cables, when what you need is a device that converts the signal from HDMI format to VGA, not one that just fits into the sockets on the screen and your Raspberry Pi. If your monitor is connected using a blue plug, and the connector has three rows on five pins in it, it’s probably a VGA monitor.

check.png TV: You can connect your Raspberry Pi to a high definition TV using the HDMI socket and should experience a crisp picture. If you have an old television in the garage, you can also press it into service for your Raspberry Pi. The Pi can send a composite video signal through an RCA cable, so it can use a TV as its display. When we tried this, it worked but the text lacked definition, which made it difficult to read. If a TV is your only option, see Appendix A for advice on tweaking the settings to get the clearest possible picture. It’s better to use a computer monitor if you can, though.

check.png USB hub: The Raspberry Pi has one or two USB sockets (depending on the model you get), but you should use a powered USB hub for two reasons. Firstly, you’re going to want to connect other devices to your Pi at the same time as your keyboard and mouse, which use two sockets. And secondly, you should use a USB hub because it provides external power to your devices and minimizes the likelihood of experiencing problems using your Raspberry Pi. Make sure your USB hub has its own power source independent of the Raspberry Pi.

check.png USB keyboard and mouse: The Raspberry Pi only supports USB keyboards and mice, so if you’re still using ones with PS/2 connectors (round rather than flat), you need to replace them.

tip.eps When the Raspberry Pi behaves unpredictably it’s often because the keyboard is drawing too much power, so avoid keyboards with too many flashing lights and features.

check.png SD card: The Raspberry Pi doesn’t have a hard disk built in to it, so it uses an SD card as its main storage. You probably have some SD cards that you use for your digital camera, although you might need to get a higher capacity one. We would recommend a 4GB SD card as a minimum, and SD cards are cheap enough now that it’s worth getting an 8GB or 16GB one. Even that isn’t much space for your files and data compared to the hard drive on a modern computer, but you can use other storage devices such as external hard drives with your Raspberry Pi too. SD cards have different class numbers that indicate how fast you can copy information to and from them. Element14 sells a class 4 SD card with the operating system preloaded on it (see Figure 1-3), and RS Components recommends a class 6 SD card to use with the Raspberry Pi.

check.png SD card writer for your PC: Many PCs today have a slot for SD cards so you can easily copy photos from your camera to your computer. If yours doesn’t, you might want to consider getting an SD card writer to connect to your computer. You’ll use it to copy Linux to an SD card for use with your Raspberry Pi, but you won’t be able to use it to copy files from your Raspberry Pi to a Windows computer. Alternatively, you can buy an SD card that has the recommended version of Linux already on it for use with the Raspberry Pi. That means you can avoid the expense of an SD card writer, but it doesn’t enable you to experiment with the different operating systems available for the Pi (see Chapter 2).


Figure 1-3: A SD card preloaded with the Raspberry Pi operating system.

check.png USB keys: USB keys (also known as flash drives or memory sticks) are fairly cheap and high capacity now (a 64GB USB key is readily affordable), which makes them an ideal complement to your Raspberry Pi. You can transfer files between your PC and your Raspberry Pi using a USB key, too.

check.png External hard drive: If you want lots of storage, perhaps so you can use your music or video collection with the Raspberry Pi, you can connect an external hard drive to it over USB. You’ll need to connect your hard drive through a powered USB hub, or use a hard drive that has its own external power source.

check.png Speakers: The Raspberry Pi has a standard audio out socket, compatible with headphones and PC speakers that use a 3.5mm audio jack. You can plug your headphones directly into it, or use the audio jack to connect to speakers, a stereo, or a TV. If you’re using a TV or stereo for sound, you can get a cable that goes between the 3.5mm audio jack and the audio input(s) on your television or stereo. You won’t always need speakers: If you’re using an HDMI connection, the audio is sent to the screen with the video signal so you won’t need separate speakers, but note that this doesn’t work if you use a DVI monitor.

check.png Power supply: The Raspberry Pi uses a Micro USB connector for its power supply, and is theoretically compatible with a lot of mobile phone and tablet chargers. In practice, many of these can’t deliver enough current (up to 700 milliamperes), which can make the Raspberry Pi perform unreliably. The resistance in the cables that connect the Pi to the power supply varies greatly too, and this can prevent peripherals like the mouse from working. It’s worth checking whether you have a charger that might do the job (it should say how much current it provides on it), but for best results, we recommend buying a compatible charger from the same company you got your Raspberry Pi from. Don’t try to power the Pi by connecting its Micro USB port to the USB port on your PC with a cable, because your computer probably can’t provide enough power for your Pi.

check.png Case: It’s safe to operate your Raspberry Pi as-is, but many people prefer to protect it from spills and precariously stacked desk clutter by getting a case for it. You can buy plastic cases on eBay (, most of which are transparent so you can still admire the circuitry and see the Pi’s LED lights. These cases typically come as simple kits for you to assemble. The Pibow ( is one of the most attractively designed cases, with layers of plastic giving it a rainbow look, side-on (see Figure 1-4). It’s designed by Paul Beech, who designed the Raspberry Pi logo. You don’t have to buy a case, though. You can go without or make your own (see Chapter 3). Whatever case you go with, make sure you can still access the GPIO pins so you can experiment with connecting your Pi to electronic circuits and try the projects in Part V of this book.


Pibow Pimoroni Ltd (

Figure 1-4: The Pibow Raspberry Pi case.

check.png Cables: You’ll need cables to connect it all up, too. In particular, you need an HDMI cable (if you’re using an HDMI or DVI monitor), an HDMI to DVI adapter (if you’re using a DVI monitor), an RCA cable (if you’re connecting to an older television), an audio cable (if connecting the audio jack to your TV or stereo), and an Ethernet cable (for networking). You can get these cables from an electrical components retailer and might be able to buy them at the same time as you buy your Raspberry Pi. Any other cables you need (for example to connect to PC speakers or a USB hub) should come with those devices.

warning_bomb.eps The Raspberry Pi has been designed to be used with whatever accessories you having lying around to minimize the cost of getting started with it but, in practice, not all devices are compatible. In particular, incompatible USB hubs, keyboards, and mice can cause problems that are hard to diagnose.

A list of compatible and incompatible devices is maintained at and you can check online reviews to see whether others have experienced difficulties using a particular device with the Raspberry Pi.

If you’re buying new devices, you can minimize the risk by buying recommended devices from Raspberry Pi retailers.

In any case, you should set a little bit of money aside to spend on accessories. The Raspberry Pi is a cheap device, but buying a keyboard, mouse, USB hub, SD cards, and cables can easily double or triple your costs, and you might have to resort to that if what you have on hand turns out not to be compatible.