This edition first published 2014
© 2014 John Wiley & Sons, Ltd.
Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.
The right of the authors to be identified as the authors of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the U.K. Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
Trademarks: Wiley and the John Wiley & Sons, Ltd. logo are trademarks or registered trademarks of John Wiley and Sons, Ltd. and/ or its affiliates in the United States and/or other countries, and may not be used without written permission. Raspberry Pi is a trademark of the Raspberry Pi Foundation. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book.
A catalogue record for this book is available from the British Library.
ISBN 978-1-118-55543-9 (paperback); ISBN 978-1-118-55556-9 (ePub); ISBN 978-1-118-55553-8 (ePDF)
To the kitchen table inventors, and their long-suffering families that have to live with them.
–Andrew Robinson
To Mike Bibby, who was the first editor to give me the opportunity to write regularly about computers and hardware. His unfailing enthusiasm about all things and his inability to take anything just on trust are an example to us all. A continuing and valued friend.
–Mike Cook
Some of the people who helped bring this book to market include the following:
VP Consumer and Technology Publishing Director
Michelle Leete
Associate Director–Book Content Management
Martin Tribe
Associate Publisher
Chris Webb
Executive Commissioning Editor
Craig Smith
Project Editor
Dana Lesh
Copy Editors
Dana Lesh, Kathryn Duggan
Technical Editor
Genevieve Smith-Nunes
Editorial Manager
Jodi Jensen
Senior Project Editor
Sara Shlaer
Editorial Assistant
Annie Sullivan
Associate Marketing Director
Louise Breinholt
Marketing Manager
Lorna Mein
Senior Marketing Executive
Kate Parrett
Marketing Assistant
Polly Thomas
Andrew Robinson is the founder of a successful embedded computing design consultancy firm based in Manchester. Passionate about education, he runs workshops and training sessions for all levels of experience, from design engineers to teachers and school children. His projects with the Raspberry Pi have appeared in the national press and on ITV, Channel 5 and BBC television. He is an Honorary Research Fellow of the University of Manchester, where previously he completed his Ph.D. in low power-embedded processors.
Andrew can trace his enthusiasm for electronics and computers back to building a working model lighthouse at the age of five.
Mike Cook, veteran technical author and electronics maker from the U.K., was born in Manchester and still lives close by. He is best known to the public for a series of over 300 articles which appeared in The Micro User, Acorn Computing and Acorn User from 1983 to 2000. These were called the “Body Building Course” and “Run the Risc” and covered the design and build of new gadgets, interfaces and peripherals for the old (vintage) BBC computer and the RISC PC. He also wrote numerous reviews, software articles and the readers’ problem page in these magazines.
Mike started work in the late sixties at an industrial electronics company in Oldham. He went on to take a degree in physical electronics at Newcastle, including a year spent working at the Admiralty Underwater Weapons establishment at Portland. His post-graduate research was in sound compression at the University of Salford. He spent over 20 years at Manchester Metropolitan University (initially Manchester Polytechnic) lecturing in physics, specialising in computer instrumentation, astronomy and image processing. Later he moved back into industry where he headed the hardware design team for the pioneering digital terrestrial set top box, and has been a development manager for security and RFID products.
He now works freelance as an embedded electronics consultant and author. His last book was The Raspberry Pi For Dummies published by Wiley.
Recently he has been designing even more things in the arena of physical computing, exhibiting at the U.K. Maker Fairs, Mini Maker Fairs and the prestigious New York World Maker fair. Mike was the recipient of a Maker of Merit Blue Ribbon at the 2013 Rome Maker Faire.
Jonathan Evans has had a life-long interest in computers and electronics. At the tender age of 10, he taught himself how to program a computer, and he quickly learned how computers and electronics could be married for a functionality to keep his siblings out of his room. He has gone on to become a distinguished IT professional with over 20 years of experience. His passion for creation and innovation combines perfectly with the Raspberry Pi phenomenon, and in his spare time he enjoys exploring projects to make the Raspberry Pi relevant to everyday life. He enjoys sharing his ideas at www.projects.privateeyepi.com
where he continues to explore the endless possibilities of this computing platform.
Sean McManus writes inspiring books and articles about computing. He contributed the chapter on Minecraft to Raspberry Pi Projects, and his previous books include Raspberry Pi For Dummies (written with Mike Cook), Scratch Programming in Easy Steps, iPad for the Older and Wiser, Microsoft Office for the Older and Wiser, and Web Design in Easy Steps. Visit his website at www.sean.co.uk
.
When we’re young, making things is second nature – painting a picture, inventing a game, telling a story, building a rocket from a washing-up liquid bottle that we’re convinced will fly all the way to the moon. Childhood is all about adventure, discovery – the quest for something new.
Although these joys don’t fade with age, it can become harder to find space and time for play and discovery as “real life” takes over. But yet, some of the greatest inventions and discoveries of history were the result of curious people not being afraid to “have a go”, often tinkering away in their own homes or garden sheds rather than high-tech well-funded engineering companies.
What’s this got to do with a book on things to do with a Raspberry Pi?
Well, after reading and having a go at some of the projects in this book you might discover the pleasure of making something with a computer can bring. Computing offers a fantastic world of new and untapped opportunities for adventure and creativity. It touches so many areas of our lives (game consoles, set top boxes and smartphones are all computers) that you can combine it with almost any other passion or hobby.
You’ll see why a sprinkling of computing is beneficial for everyone, and that a moment of personal creativity on the kitchen table can have a much bigger impact. You’ll also discover the story behind a particular credit-card sized computer.
World-changing inventions can come from unconventional places.
Orville and Wilbur Wright were two ordinary brothers from Ohio who owned a bicycle shop. Fascinated with the workings of these simple machines, they became convinced that they could build a flying machine. And they did. In 1903, they launched the world’s first aeroplane. Nearly a century later, as HIV/AIDS swept through Africa, Trevor Baylis, an ex-stuntman, became convinced he could help. He sat in his suburban garden shed and invented an inexpensive and durable wind-up radio for use across Africa to spread simple health messages and undoubtedly prevented many, many deaths. Steve Jobs and Steve Wozniak, the founders of Apple, both learned about electronics and computers from experimenting in their bedrooms and family garages. These are just three examples that show the worldwide impact on millions tinkering at home can have.
Many inventors can clearly imagine what they want to make, but might not know how to build it. But, spurred on by the joy of creativity, they teach themselves the skills needed to build what they could imagine. Wozniak and Jobs developed their skills this way, taking apart existing appliances, figuring out how they work and putting them back together. Sometimes the appliances would be enhanced by tinkering, and sometimes they’d no longer work at all! But they weren’t put off; sometimes it was just about discovering how something worked, or the journey to overcome technical adversity, rather than producing a polished product.
It is ironic that the birth of Apple computers was a result of poking around in the innards of appliances. Nowadays, computers are sold as sleek, refined aluminium caskets of magic, sealing in opportunities to experiment and discover how they actually work. In a continual quest to add value to their products, manufacturers lure customers with the promise of easy-to-use products and an effortless user experience with your every need taken care of.
Unfortunately it’s not been a smooth journey. Rarely do modern computer systems do exactly what users want. How often are we left frustrated by a computer system failing, consoled by the manufacturer’s line that “that will be fixed in the next update” or “you need to buy the next version if you want it to do that”? For the technologically fearless, these statements are more like rallying cries, an excuse to tinker until the computer does what they really want. But these days, there are few people brave or skilled enough to roll their sleeves up and get inside.
Computers really are everywhere, pervading every aspect of our lives. As well as the laptop, desktop and smartphone, just think about the computers behind life support systems and medical records in our hospitals, in banking and shopping keeping the economy going, in manufacturing and our food-supply chain. They are key for our communications, powering digital TV and radio and mobile phone networks, as well as the Internet. With computers so integral to the functioning of our media, commerce and government, it seems odd that so many of us are ignorant of how they work.
Given how widespread the reliance on computers is, think how much we could all benefit from a little bit more understanding. Business leaders and politicians could make more informed decisions on projects involving computers, and the man-on-the-street would be less likely to fall prey to online scams or be duped by overimpressive advertising claims about products. They’d have the skills to make computers work for them to improve their lives.
I see similarities between computing and cooking. Cooking has recipes, which is about following steps. It is about making meals, consisting of sets of dishes. To make an apple pie, you need to break down the task into manageable elements (making the pastry, coring the apples, baking for just the right amount of time), all of which add to a complete (and hopefully tasty) apple pie. This is an example of abstraction, and is key to mastering computing. The problem-solving and logical-thinking techniques, such as managing abstraction, that are developed in computing are valuable to other aspects of life.
We teach our children how to cook, not because we want to train them to become professional chefs, but because we view it as an essential life skill. Without it, we condemn our children to a lifetime of preheating ready meals, often unfulfilling and expensive. For many people, learning the basic skills is the start of a lifelong love of cooking. They see it as an outlet for their creativity, perhaps starting with a recipe and adapting it to make it their own. It’s a social occupation, a chance to show achievements and discuss techniques, challenges and adventures around a lively dinner table.
I’d argue that learning to use computers has parallels with learning to cook. Everyone needs the basic skills. Some may use those skills to go on to become professional programmers, but I’d hope that for most people it is an opportunity for creativity, as well as a survival skill in today’s modern environment.
However, given the need for more people to learn more about how computers work and the reliance on them, it’s also ironic that getting into computing has become more difficult with modern computers. That is, until a certain credit-card–sized computer came along. . . .
For most people, beginning to experiment on a £1000 laptop, putting precious data at risk is a daunting prospect. I’d think twice before putting all my digital photos, my music collection and my online banking at risk! Games consoles and some phones actively prevent people from creating their own games and apps, presumably to protect revenue by forcing consumer to buy manufacturer’s products.
With the desire to share the fun of computing and the need for more people to know how computers worked, Eben Upton created a small, cheap computer on his kitchen table. With the help of Dr. Rob Mullins, Professor Alan Mycroft and Jack Lang from Cambridge University; Pete Lomas, an expert in hardware; and David Braben, the Raspberry Pi Foundation was born, a charity that set out to promote the study of computer science and related topics, especially at the school level, and to put the fun back into learning computing.
The Raspberry Pi Foundation aimed to open up the world of computing by creating a hardware device that was pocket-money affordable, so it was accessible to everyone, and there’d be no need to worry about experimenting with it. It was unboxed to make it easy to tinker with.
In 2011, after five years’ intense kitchen-table engineering, the first prototype Raspberry Pi computers were produced. After a feature about the Raspberry Pi on technology journalist Rory Cellan-Jones’s blog went viral the Foundation wondered if they were at the early stages of something bigger than they were expecting.
After some clever engineering to allow the Raspberry Pi to be built cheaply enough to be sold for $25, an initial batch of 10,000 went on sale on 29th February 2012 at 6 a.m. A few minutes later, they had sold out. Eighteen months later, 1.75 million had been sold worldwide.
During the development of the Raspberry Pi I’d been working on public engagement projects at the University of Manchester to encourage more people into computing.
I’d been following the Raspberry Pi from an early stage, and thought it had great potential. Like thousands of other engineers, I was also very excited by the technology crammed in this tiny PCB of components. I was also aware that for most people less familiar with computers, the same PCB wouldn’t be particularly exciting, and perhaps a scary mass of wires, components and metal. Like the Foundation, I wanted to share the wonder and joy computing could bring.
The big advantage of the Raspberry Pi was that it could be put it in places you couldn’t put a PC. I wanted the Raspberry Pi to be relevant to what people are interested in. To make it easy to connect to the Raspberry Pi, I came up with the PiFace Digital interface, developed at home on the kitchen table in my free evenings and weekends. I’m still amazed when I see people all over the world posting videos online showing what they’re doing with the Raspberry Pi and PiFace. I’ve seen children building robots, door-entry systems for the elderly, games and industrial applications in banks and railway stations.
This book aims to answer the question “You’ve got a Raspberry Pi – now what?” and is packed full of fun Raspberry Pi projects to inspire you.
This book is divided into three parts. There is some progression, but after you’ve got your Raspberry Pi up and running it should be fairly easy to dip into any of the other chapters. You can just follow the step-by-step instructions to get results quickly, but don’t be afraid to experiment and make them your own. That’s where the real fun lies! Background information is provided that will help you learn the skills you will need if you want to extend the projects.
At the end of each chapter, there are ideas and suggestions for extensions, but you will probably have your own too. We want to see what you create, so share your work with social media such as Facebook, Twitter and YouTube and tag them with RaspberryPiProjects.
Some code listings are available to download from the companion website at www.wiley.com
/go/raspberrypiprojects
if you get really stuck, but part of learning to program is about typing code in, so not all the code is provided!
Much of the background information is relevant to the classroom, and the book can be used to supplement teaching the new U.K. computing qualifications. If you’re a teacher, look out for supporting information that can help students learn through Raspberry Pi projects.
This part will take you through plugging together your Raspberry Pi and installing the software, plus introduces you to Python:
This contains some fun software projects:
This contains some exciting and challenging hardware projects:
Computers are set to be an ever-bigger part of our lives and touch more areas. Systems will be more complex with more connectivity. In the future your washing machine and other appliances in your home will likely talk to your smartphone. And we’ll all need more computing skills to master them. New ways of using computers will mean that there will be new areas for adventure and opportunities to change people’s lives and solve problems in the world.
One word of warning before you begin your adventure: After you start you might never stop! Electronics and coding can be addictive; who knows what you might go on to make with the skills you learn from this book.
Building and making is incredibly rewarding and satisfying. We want to get more people of the world to become producers of technology rather than consumers. The projects in this book are starting points – but then the real rewards come from making the project your own and seeing your own ideas become reality.
Welcome to the world of digital making. Are you ready to invent the future?