Contents in Detail
ARDUINO PROJECT HANDBOOK
25 PRACTICAL PROJECTS TO GET YOU STARTED
MARK GEDDES
SAN FRANCISCO
ARDUINO PROJECT HANDBOOK. Copyright 2016 by Mark Geddes.
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.
Printed in USA
First printing
20 19 18 17 16 1 2 3 4 5 6 7 8 9
ISBN-10: 1-59327-690-7
ISBN-13: 978-1-59327-690-4
Publisher: William Pollock
Production Editor: Serena Yang
Cover and Interior Design: Beth Middleworth
Developmental Editor: Liz Chadwick
Technical Reviewer: Christopher Stanton
Copyeditor: Rachel Monaghan
Compositor: Serena Yang
Proofreader: James Fraleigh
Circuit diagrams made using Fritzing (http://fritzing.org/).
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: 415.863.9900;
www.nostarch.com
Library of Congress Cataloging-in-Publication Data:
Names: Geddes, Mark.
Title: Arduino project handbook : 25 practical projects to get you started /
by Mark Geddes.
Description: San Francisco : No Starch Press, [2016] | Includes index.
Identifiers: LCCN 2015033781| ISBN 9781593276904 | ISBN 1593276907
Subjects: LCSH: Programmable controllers. | Microcontrollers--Programming. |
Science projects--Design and construction. | Arduino (Programmable
controller)
Classification: LCC TJ223.P76 G433 2016 | DDC 629.8/9551--dc23
LC record available at http://lccn.loc.gov/2015033781
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. 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.
CAMERON AND JEMMA, YOU ARE THE CREATORS AND MAKERS OF THE FUTURE. THIS BOOK IS FOR YOU!
CONTENTS IN DETAIL
ACKNOWLEDGMENTS
Many thanks to the fantastic team at No Starch Press, particularly Elizabeth Chadwick and Serena Yang, for their support and guidance in the creation of this book. Thanks to Christopher Stanton for his technical reviews and suggestions.
This book wouldnt exist if it wasnt for the inspirational Arduino founders: Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Thank you for introducing me and the world to the wonder that is Arduino. Thanks also to Ken Shirriff, Warwick Smith, Steven de Lannoy, and Abdullah Alhazmy for kind permission to reproduce their projects.
I have to thank my wonderful wife, Emily, for being so supportive and patient over the last year and for freeing up a room in our house as a man cave so I could put together all these projectsand for resisting the temptation to tidy it on a daily basis!
Thank you to my parents, Frank and Lorna, for allowing me the freedom as a child to take things apart and for not complaining when I had wires everywhere. If not for their support, I wouldnt have the passion for electronics and gadgets that I still have today. Thanks also to David and Linda for their fantastic support, encouragement, and belief.
INTRODUCTION
The Arduino is a small, inexpensive computer that can be programmed to control endless creations limited only by your imagination. As youll soon see, the Arduino can be used to make a whole host of projects, like a ghost detector, joystick-controlled laser, electronic die, laser trip wire alarm, motion sensor alarm, keypad entry system, and many others. All of these projects are easy to build and have one thing in commonthey use the power of the Arduino.
In the early 1980s, I picked up a great Penguin paperback titled something like Gadgets and Gizmos, hidden away in a local bookstore. The projects were simple ones like making a working lighthouse using flashlight bulbs and building a revolving display table using an old clock. The ideas in that book sparked my imagination, and Ive been creating ever since.
My curiosity led me to take apart various electrical items to experiment with and find out how they worked. I usually struggled to put them back together but amassed a good selection of components to tinker with. (This is a great way of gathering lots of parts, by the way.)
I remember wiring together a string of small flashlight bulbs to make floodlights for my Subbuteo table-top soccer game and creating a loudspeaker system to blast out music at the halftime break in a game. I even managed to extract some LEDs from a Star Wars toy, only to burn them out because I didnt understand what a resistor was at the time. I used small motors, buzzers, and solar cells to create burglar alarms and super whizzy cars, and I burned out a few motors too!
At roughly the same time (1983), Sinclair Research in the United Kingdom launched the ZX Spectrum 48k microcomputer, introducing home computing to the UK mass market. (The United States had its Commodore 64.) While intended as a serious computer, the ZX Spectrum inadvertently lent itself more to gaming due to its inclusion of the simple programming language BASIC. As a result, software houses sprouted in bedrooms across the country as people rushed to build games for the ZX.
This sparked my interest in programming, but at the time I couldnt combine my two passions. Physical computing, where software and hardware react to the physical world, was around in the 80s but confined to the realm of very high-end computing and robotics, way out of reach of most households. Now, some 30 years later, with the introduction of the Arduino, I find myself tinkering again with electronics, but this time I can use programming to bring the projects to life.
THE ARDUINO REVOLUTION
In simple terms, the Arduino is a small computer that can be programmed to connect and control various electronic parts. The Arduino has a number of pins that can be set as either input, which means they can receive data from items such as switches, buttons, and sensors, or output, which means they send data to control items such as motors, lights, and buzzers. This type of programmable development board is better known as a microcontroller.
The Arduino project began in Ivrea, Italy, in 2005 with the goal of creating a device to control student-built interactive design projects that would be less expensive than other prototyping systems available at the time. Founders Massimo Banzi and David Cuartielles named the project after a local bar called Arduino (an Italian masculine first name meaning strong friend).
The Arduino board is composed of two main elements: the hardware, or microcontroller, which is the brain of the board, and the software that youll use to send your program to the brain. The software, called the Arduino