Table of Contents
Introduction
Chapter 1: Test Your Reactions
Welcome to the Embedded World!
Good Practice
Obtaining Components
An Interface Board
PiFace Digital
Setting up PiFace Digital
Installing PiFace Digital Software
Connecting PiFace Digital
Using the Emulator
Interfacing with Python
Turning a Light On
Reading a Switch
The Reaction Timer
Meet PiFace Digital’s Connectors
Connecting a Switch and an LED
Playing with the Reaction Timer
What Will You Interface?
Chapter 2: The Twittering Toy
Hacking the Toy
Building the Chicken
Wiring
Making It Talk
Using Espeak in Python
Testing the Espeak module
Making It Move
Creating Classes
Creating Objects
Testing As You Go
Connecting to Twitter
Building and Installing Python Modules
Talking to Twitter
Putting It All Together
Wrapping Up
More Ideas
Chapter 3: Disco Lights
Defining Your Sequence
Getting the Code to Do More
A Small Detour into Theory
Designing the Sequencer
Implementing the Sequencer
The Lights
Using Longer Strip Lights
Making the Lights Move
Designing the Circuit
Building the Circuit
Running the Circuit
Over to You
Appendix A: Getting Your Raspberry Pi Up and Running
Getting the OS on an SD Card
Connecting a Display
Connecting to a Network
Booting the Operating System
Powering Up!
Common Problems
If You Need More Help
Appendix B: Introductory Software Project: The Insult Generator
Variables
Strings
Lists
Functions
Conditional Behaviour
Making Your Own Functions
Creating Loops
More Raspberry Pi Resources
Raspberry Pi® Hardware Projects, Volume 1
This edition first published 2013
© 2013 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 UK 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 Wiley logo are trademarks or registered trademarks of John Wiley and Sons, Inc. 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-58894-9 (ePub); ISBN 978-1-118-72391-3 (ePDF)
Some of the people who helped bring this book to market include the following:
Editorial and Production
VP Consumer and Technology Publishing Director
Michelle Leete
Associate Director–Book Content Management
Martin Tribe
Associate Publisher
Chris Webb
Executive Commissioning Editor
Craig Smith
Assistant Editor
Ellie Scott
Project Editors
Dana Lesh, Kathryn Duggan
Copy Editors
Dana Lesh, Kathryn Duggan
Technical Editor
Genevieve Smith-Nunes
Editorial Manager
Jodi Jensen
Senior Project Editor
Sara Shlaer
Editorial Assistant
Leslie Saxman
Marketing
Associate Marketing Director
Louise Breinholt
Marketing Manager
Lorna Mein
Senior Marketing Executive
Kate Parrett
Composition Services
Compositors
Carrie A. Cesavice, Jennifer Goldsmith
Proofreaders
Melissa Cossell, Dwight Ramsey
Introduction
You’ve got a Raspberry Pi – now what? This book has the answer; it’s packed full of fun Raspberry Pi projects to inspire you. From getting your Pi generating comedy insults, testing your reactions and building a talking animatronic toy that tweets to building your own disco light show, prepare to be entertained and amazed by your credit card–sized computer.
One word of warning: 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.
Appendix A, “Getting Your Raspberry Pi Up and Running”, is a beginner’s guide to your first steps with the Raspberry Pi. If you’ve never coded before, Appendix B, “Introductory Software Project: The Insult Generator”, will get you started programming in Python. Chapter 1, “Test Your Reactions”, will get you wiring up simple computer-controlled circuits. Chapter 2, “The Twittering Toy”, will show you how to make your code talk to Twitter and get you hacking household items. Chapter 3, “Disco Lights”, shows you how to control LED strips and make them dance in time to the music. Along the way you will pick up the skills you need to develop your own ideas to make projects work exactly how you want them to.
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 – step by step, they’re easy to follow so you can get results quickly. But then the real satisfaction can come, that which comes from making the project your own. At the end of each chapter there are ideas and suggestions to extend the project, together with background information to point you in the right direction. The real addictive fun begins when you see your own ideas become reality.
Welcome to the world of digital making.