Arduino Cookbook
Arduino Cookbook
Michael Margolis
Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
Arduino Cookbook by Michael Margolis Copyright © 2011 Michael Margolis and Nicholas Weldin. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or
[email protected]
Editors: Simon St. Laurent and Brian Jepson Production Editor: Teresa Elsey Copyeditor: Audrey Doyle Proofreader: Teresa Elsey
Indexer: Lucie Haskins Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano
Printing History: March 2011:
First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Arduino Cookbook, the image of a toy rabbit, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
ISBN: 978-0-596-80247-9 [LSI] 1299267108
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii 1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Installing the Integrated Development Environment (IDE) 1.2 Setting Up the Arduino Board 1.3 Using the Integrated Development Environment (IDE) to Prepare an Arduino Sketch 1.4 Uploading and Running the Blink Sketch 1.5 Creating and Saving a Sketch 1.6 Using Arduino
4 6 8 11 13 15
2. Making the Sketch Do Your Bidding . . . . . . . . . . . . . . . . .