acknowlEdGMEnts We both want to thank the No Starch Press team who have done such a great job producing this book Special thanks to Liz Chadwick for the invitation to write this book and for her endless patience editing our non-native English writing We also want to thank Laurel Chun for her attention to detail and for producing this book’s beautiful layout Thanks to Les Pounder for his technical contribution and suggestions Many thanks to the Raspberry Pi Foundation for developing this tiny but powerful computer that made electronics and coding more accessible to general public We must also thank our friends and family for being supportive throughout this entire journey Finally we would like to thank the Random Nerd Tutorials community who indirectly have also made this book possible Writing this book wouldn’t have been possible if it wasn’t for Sara Santos’s work and support and her tireless effort to meet all the deadlines I thank her greatly Rui Santos I would like to thank my coauthor Rui Santos for inviting me to take part in this journey Thanks for showing me that we can work in something we love we just have to chase our dreams Sara Santos x v i a c k n o w l E d G M E n ts
intRoduction Have you ever considered that you could buy a computer for 35 And no we’re not talking about an ancient computer from a pawn shop We’re talking about the Raspberry Pi a computer board about the size of a credit card But don’t be fooled by its fragile appearance it’s much more powerful than it seems The Raspberry Pi was developed in the United Kingdom by Eben Upton founder of the Raspberry Pi Foundation Upton and his colleagues noticed a decline in the skills of students applying to study computer science at the University of Cambridge and real ized it was because newer generations of students had grown up with computers that were easy to use The students never needed to learn how computers really work and didn’t have much oppor tunity to program or tinker Upton developed the Raspberry Pi as a way to promote teaching basic computer science in schools This is why the Pi is a bare board rather than a computer in a case so everyone can see the components of a computer More than ten million Raspberry Pi boards have been sold since it was first introduced in 2012 The Raspberry Pi has become popular not just among students but also electronics hobbyists tinkerers computer scientists and kids of all ages The Raspberry Pi can work as a regular computer you can surf the web send emails write documents watch videos and so on but that’s not its main purpose The Pi is something that you can experiment with hack and play with to build your own pro grams and inventions The Raspberry Pi and similar boards made it not only possible but easy to get involved in the world of electronics and programming resulting in an outpouring of creative inventions all over the globe Now it’s your time to invent something Who Is ThIs Book For This book is suitable for any beginners who want to make the most of the Raspberry Pi whether that’s kids who want to discover the world of electronics and programming parents and educators who want to help teach children and students or hobbyists and makers who want to use the Raspberry Pi to bring their ideas to life xvii intRoduction
We don’t assume any previous knowledge about the Raspberry Pi circuits or programming If you do have some basic skills this book will help develop them further and give you ideas for what to do next ABouT ThIs Book 20 Easy Raspberry Pi Projects is a collection of 20 projects to build with the Raspberry Pi We believe that the best way to discover new concepts is through practice and a project book is an excellent way to get started The book starts with a quick introduction to the Raspberry Pi and the Python programming language and then jumps into the proj ects The book follows a learn-by-doing approach which means you don’t need to spend countless hours learning theoretical concepts before actually building something cool You’ll learn by building fun and interactive projects like a home surveillance system and a Wi-Fi controlled robot You’ll also design user-friendly interfaces to control electronics make Internet of Things projects build a website create your own games and much more Don’t worry if you don’t have any experience programming or making circuits Each project gives you step-by-step instructions to set up the circuits schematic diagrams and the code to program the Pi You can copy the code from the book or you can go to https www nostarch com RaspberryPiProject and download it Your Pi learning shouldn’t be restricted to the projects in this book and that’s why all projects have a Taking it Further section where we offer suggestions for developing your projects further and combining concepts learned throughout the book to build more com plicated and interesting things We hope that by the end of the book you’ll have the necessary skills to bring your own project ideas to life WhAT D o You NeeD For ThIs Book The projects in this book were designed using the Raspberry Pi 3 board If you have an older model of the Pi board you can still follow along but projects will be easiest to build with a Raspberry Pi 3 Older versions have lower performance and really old versions have fewer GPIO pins We don’t know when or if a Raspberry Pi 4 will be released but so far all Raspberry Pi releases have been compatible with older boards so future versions should also be compatible with the proj ects in this book xviii intRoduction