PREFACE

The Raspberry Pi is rapidly becoming a worldwide phenomenon. People are waking up to the possibility of a $35 (U.S.) computer that can be put to use in all sorts of settings—from a desktop workstation to a media center to a controller for a home automation system.

This book explains in simple terms, to both nonprogrammers and programmers new to the Raspberry Pi, how to start writing programs for the Pi in the popular Python programming language. It then goes on to give you the basics of creating graphical user interfaces and simple games using the pygame module.

The software in the book mostly uses Python 3, with the occasional use of Python 2 where necessary for module availability. The Raspbian Wheezy distribution recommended by the Raspberry Pi Foundation is used throughout the book.

The book starts with an introduction to the Raspberry Pi and covers the topics of buying the necessary accessories and setting everything up. You then get an introduction to programming while you gradually work your way through the next few chapters. Concepts are illustrated with sample applications that will get you started programming your Raspberry Pi.

Four chapters are devoted to programming and using the Raspberry Pi’s GPIO connector, which allows the device to be attached to external electronics. These chapters include three sample projects—a LED lighting controller, a LED clock, and a Raspberry Pi–controlled robot, complete with ultrasonic rangefinder.

Here are the key topics covered in the book:

Images Python numbers, variables, and other basic concepts

Images Strings, lists, dictionaries, and other Python data structures

Images Modules and object orientation

Images Files and the Internet

Images Graphical user interfaces using Tkinter

Images Game programming using pygame

Images Interfacing with hardware via the GPIO connector

Images Sample hardware projects

All the code listings in the book are available for download from the book’s website at www.raspberrypibook.com, where you can also find other useful material relating to the book, including errata.

Simon Monk