ARDUINO ROBOT BONANZA
ABOUT THE AUTHOR
Gordon McComb has written 65 books and thousands of magazine articlesover a million copies of his books are in print, in more than a dozen languages. For 13 years, Gordon wrote a weekly syndicated newspaper column on computers and high technology, which reached several million readers worldwide. Hes a regular contributor to SERVO Magazine and other publications, and maintains an active Web site dedicated to teaching the art of science of robot building. He is the author of the best-selling Robot Builders Bonanza, now in its fourth edition.
ARDUINO ROBOT BONANZA
GORDON McCOMB
New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto
Copyright 2013 by The McGraw-Hill Companies. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication.
ISBN: 978-0-07-178278-4
MHID: 0-07-178278-8
The material in this e-Book also appears in the print version of this title: ISBN: 978-0-07-178277-7, MHID: 0-07-178277-X
McGraw-Hill e-Books are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at .
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
McGraw-Hill, the McGraw-Hill Publishing logo, TABTM, and related trade dress are trademarks or registered trademarks of McGraw-Hill and/or its affiliates in the United States and other countries and may not be used without written permission. All other trademarks are the property of their respective owners. McGraw-Hill is not associated with any product or vendor mentioned in this book.
TERMS OF USE
This is a copyrighted work and McGraw-Hill and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS. THE McGRAW-HILL COMPANIES AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
For my mother,
Edna Kathryn Lane Forbes
19202012
CONTENTS
ACKNOWLEDGMENTS
Special thanks go to Ken Gracey, Matt Gilliland, Jim Carey, and my many friends at Parallax; to Jim Frye of Lynxmotion; to Nathan Seidle, Pete Dokter, and Robert Cowan of SparkFun; to Gerry Coe of Devantech; to Russell Cameron, Claudia, and the crew at DAGU; to Roger Stewart and the editors at McGraw-Hill Education; and to my agent Matt Wagner.
And as always, to my wife Jennifer.
INTRODUCTION
THIS IS YOUR ROBOT WITH AN ARDUINO BRAIN
When I first started building robots, the microprocessor had not yet been invented. Robot brains were limited to hand-wired boards filled with gompy resistors, super-expensive transistors, and maybe even a relay or two.
Today we have microcontrollers, wonderful micro-miniaturized wonders that combine a computer with the ability to directly connect to lights, alarms, motors, solenoids, sensors, and other physical things. In fact, this whole concept now goes by the catchphrase physical computing. I mention this because physical computing plays directly into building robots. Thats why microcontrollers like the Arduino are so important in robotics.
The Arduino, first designed to help student designers integrate electronics and mechanics into their work, is one of the most popular microcontrollers now available. Its meant as a tool for building projects that sense and control their nearby world.
The Arduino is like a brain in a jar by itself it lacks the ability to detect its environment or manipulate anything. Its up to you to hook up your choice of sensors, motors, and other control electronics, then program the Arduino to do your bidding. And heres where this book comes in: Arduino Robot Bonanza helps you build a half-dozen robots that use the Arduino as a central brain. It shows you how to wire things up, then write programs so your bot follows your commands.
The projects in Arduino Robot Bonanza are designed to be reproducible using ordinary shop tools and average construction skills. Theres no cutting heavy metal or welding, and each of the six robots is constructed using parts that are commonly available. None of the projects rely on hard-to-find or surplus components. While robot building can be an expensive endeavor, all plans in this book favor lower-cost parts, and encourage reuse.