Learn Robotics with Raspberry PI
LEARN ROBOTICS WITH RASPBERRY PI
BUILD AND CODE YOUR OWN MOVING, SENSING, THINKING ROBOTS
BY MATT TIMMONS-BROWN
SAN FRANCISCO
LEARN ROBOTICS WITH RASPBERRY PI. Copyright 2019 by Matt Timmons-Brown.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
ISBN-10: 1-59327-920-5
ISBN-13: 978-1-59327-920-2
Publisher: William Pollock
Production Editor: Janelle Ludowise
Cover Illustration: Josh Ellingson
Cover Design: Mimi Heft
Interior Design: Beth Middleworth
Developmental Editor: Liz Chadwick
Technical Reviewer: Jim Darby
Copyeditor: Rachel Monaghan
Compositor: Kim Scott, Bumpy Design
Proofreader: James Fraleigh
Circuit diagrams made using Fritzing (http://fritzing.org/).
The following images are reproduced with permission:
).
For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900;
www.nostarch.com
Library of Congress Cataloging-in-Publication Data:
Names: Timmons-Brown, Matt, author.
Title: Learn robotics with Raspberry Pi : build and code your own moving,
sensing, thinking robots / Matt Timmons-Brown.
Description: San Francisco : No Starch Press,Inc., [2019]
Identifiers: LCCN 2018042503 (print) | LCCN 2018048396 (ebook) | ISBN 9781593279202 (print) | ISBN 1593279205 (print) | ISBN 9781593279219 (ebook) | ISBN 1593279213
(ebook)
Subjects: LCSH: Robotics. | Raspberry Pi (Computer)
Classification: LCC TJ211 (ebook) | LCC TJ211 .T579 2019 (print) | DDC
629.8/9--dc23
LC record available at https://lccn.loc.gov/2018042503
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Raspberry Pi is a trademark of the Raspberry Pi Foundation. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is distributed on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
TO MY PARENTS, REBECCA AND JEFF, FOR SUPPORTING YOUR SONS STRANGE PASSION FOR PI AND ALWAYS BELIEVING IN ME. THANK YOU FOR YOUR INVALUABLE ADVICE AND UNLIMITED LOVE.
I DEDICATE THIS BOOK TO YOU.
CONTENTS
CONTENTS IN DETAIL
ACKNOWLEDGMENTS
This publication would not have been possible without the help, support, and hard work of a plethora of different peoplethe full list of which would probably span the length of this entire book.
Firstly, I would like to thank Liz Chadwick, Janelle Ludowise, Bill Pollock, and the entire team at No Starch Press for persuading me to write a book in the first place and for making Learn Robotics with Raspberry Pi a reality. Thank you also to Jim Darby, Raspberry Pi extraordinaire and friend, for diligently turning his hands to the technical review.
Without the Raspberry Pi computer, not only would this book not exist, but neither would my fascination and love for computer science as I know it today. For this, I have to thank the Raspberry Pi Foundation and everybody involved with it. The impact of the Pi and the Foundations work has changed and improved the world in so many ways. In particular, I am indebted to Eben Upton for his years of advice, mentorship, and supportand for writing the foreword to this book too.
Raspberry Pi would be nothing without the immense, world-wide community that surrounds it. Regardless of whether youre brand new to this community or have been in it since the start, thank you... And extra thanks to all those that have supported my YouTube channel, come to any of my talks, or smiled at me at Pi events!
Thanks to Phil Howard, Ben Nuttall, and Simon Beal for their Python 3 support and expertise throughout the writing process. To Paul Freakley, Brian Corteil, and Rob Karpinskithank you for helping me become a maker and giving me access to crazy laser cutters, 3D printers, and more.
Thank you to Tim Hanbury-Tracy for giving me your place in the pre-order queue for the original Raspberry Pi back in 2012how different my life would have been if not for your generosity.
Finally, thank you to my friends and family; without you my journey in computer science and the writing of this book would not be possible. In particular, thank you to my parents, Rebecca and Jeff, for your unending love, support, and guidance.
FOREWORD
When we founded the Raspberry Pi Foundation in 2008 and set out to develop the Raspberry Pi computer, we saw it primarily as a platform for software development. If you had asked me then what our predominant educational use case would be in 2018, I would probably have cited game development: after all, that had been my route into computing back in the late 1980s.
In the six years since we launched the first Raspberry Pi, the community around our little educational computer has grown beyond our wildest dreams. Weve seen children and adults all over the world using Raspberry Pi to learn engineering skills; weve sent two units to the International Space Station, where they have run code developed by over 3,000 teams of young people from across Europe; and weve trained thousands of educators to deliver compelling lessons using our library of free educational resources.
All this has been a surprise, but the biggest surprise for me has been the popularity of physical computing projects: not just writing code, but using it to sense, control, and interact with the real world. While moving sprites around on the screen is cool, moving physical objects around the room is cooler. The 40-pin GPIO connector, included at my colleague Pete Lomass insistence, has proven in many ways to be the single most useful feature on the board.
Its a truism that platforms are only as good as their documentation, and for many beginners, the learning curve for physical computing can appear daunting. Learn Robotics with Raspberry Pi provides a gentle introduction to this exciting field, building up from the simplest input and output examples to a robot which incorporates wireless control and is capable of autonomously tracking and following lines and objects.
My hope is that in twenty or thirty years, a handful of people will look back on Raspberry Pi with the same affection I have for the BBC Micro and Commodore Amiga. If that happens, Im sure some of those people will have Learn Robotics with Raspberry Pi