ebook img

Arduino A Quick Start Guide.pdf - unrobotica PDF

284 Pages·2011·12.03 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Arduino A Quick Start Guide.pdf - unrobotica

What Readers Are Saying About Arduino: A Quick-Start Guide The most comprehensive book on the Arduino platform I have read. Loaded with excellent examples and references, Arduino:AQuick-Start Guide gets beginners up and running in no time and provides experi- enced developers with a wealth of inspiration for their own projects. Haroon Baig Creator of the Twitwee Clock, http://www.haroonbaig.com Excellently paced for those who have never experimented with elec- tronics or microcontrollers before and packed with valuable tidbits even for advanced Arduino tinkerers. Georg Kaindl Creator, Arduino DHCP, DNS, and Bonjour libs The Arduino platform is a great way for anyone to get into embedded systems, and this book is the road map. From first baby steps to com- plex sensors and even game controllers, there is no better way to get going on the Arduino. Tony Williamitis Senior embedded systems engineer I recommend this engaging and informative book to software develop- ers who want to learn the basics of electronics, as well as to anyone looking to interface their computers with the physical world. René Bohne Software developer and creator of LumiNet Arduino A Quick-Start Guide Maik Schmidt The Pragmatic Bookshelf Raleigh,NorthCarolina Dallas,Texas Many of the designations used by manufacturers and sellers to distinguish their prod- uctsareclaimedastrademarks.Wherethosedesignationsappearinthisbook,andThe Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The PragmaticProgrammer,PragmaticProgramming,PragmaticBookshelfandthelinkingg devicearetrademarksofThePragmaticProgrammers,LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibilityfor errorsor omissions, or for damages that may result from theuseofinformation(includingprogramlistings)containedherein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatictitles,pleasevisitusathttp://www.pragprog.com. Theteamthatproducedthisbookincludes: Editor: SusannahPfalzer Indexing: PotomacIndexing,LLC Copyedit: KimWimpsett Layout: SamuelLanghorne Production: JanetFurlow Customersupport: EllieCallahan International: JulietBenda Copyright©2011PragmaticProgrammers,LLC. Allrightsreserved. Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmit- ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise,withoutthepriorconsentofthepublisher. PrintedintheUnitedStatesofAmerica. ISBN-10:1-934356-66-2 ISBN-13:978-1-934356-66-1 Printedonacid-freepaper. P1.0printing,Janurary,2011 Version:2011-1-24 Download from Wow! eBook <www.wowebook.com> ForYvonne. Thegreatestlittlesisteronearth. Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> Contents Acknowledgments 11 Preface 13 Who Should Read This Book . . . . . . . . . . . . . . . . . 14 What’s in This Book . . . . . . . . . . . . . . . . . . . . . . 14 Arduino Uno and the Arduino Platform . . . . . . . . . . . 16 Code Examples and Conventions . . . . . . . . . . . . . . . 16 Online Resources . . . . . . . . . . . . . . . . . . . . . . . . 17 The Parts You Need 18 Starter Packs . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Complete Parts List . . . . . . . . . . . . . . . . . . . . . . . 19 I Getting Started with Arduino 22 1 Welcome to the Arduino 23 1.1 What You Need . . . . . . . . . . . . . . . . . . . . . 24 1.2 What Exactly Is an Arduino? . . . . . . . . . . . . . 24 1.3 Exploring the Arduino Board . . . . . . . . . . . . . 25 1.4 Installing the Arduino IDE . . . . . . . . . . . . . . . 31 1.5 Meeting the Arduino IDE . . . . . . . . . . . . . . . . 33 1.6 Compiling and Uploading Programs . . . . . . . . . 38 1.7 Working with LEDs . . . . . . . . . . . . . . . . . . . 41 1.8 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 43 1.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 44 2 Inside the Arduino 46 2.1 What You Need . . . . . . . . . . . . . . . . . . . . . 46 2.2 Managing Projects and Sketches . . . . . . . . . . . 47 2.3 Changing Preferences . . . . . . . . . . . . . . . . . . 48 2.4 Using Serial Ports . . . . . . . . . . . . . . . . . . . . 49 2.5 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 60 2.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 61 Download from Wow! eBook <www.wowebook.com> CONTENTS 8 II Eight Arduino Projects 62 3 Building Binary Dice 63 3.1 What You Need . . . . . . . . . . . . . . . . . . . . . 63 3.2 Working with Breadboards . . . . . . . . . . . . . . . 64 3.3 Using an LED on a Breadboard . . . . . . . . . . . . 66 3.4 First Version of a Binary Die . . . . . . . . . . . . . . 69 3.5 Working with Buttons. . . . . . . . . . . . . . . . . . 74 3.6 Adding Our Own Button . . . . . . . . . . . . . . . . 79 3.7 Building a Dice Game. . . . . . . . . . . . . . . . . . 80 3.8 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 86 3.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 87 4 Building a Morse Code Generator Library 88 4.1 What You Need . . . . . . . . . . . . . . . . . . . . . 88 4.2 Learning the Basics of Morse Code . . . . . . . . . . 88 4.3 Building a Morse Code Generator . . . . . . . . . . . 89 4.4 Fleshing Out the Generator’s Interface . . . . . . . . 91 4.5 Outputting Morse Code Symbols . . . . . . . . . . . 92 4.6 Installing and Using the Telegraph Class . . . . . . 94 4.7 Final Touches . . . . . . . . . . . . . . . . . . . . . . 97 4.8 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 99 4.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 100 5 Sensing the World Around Us 102 5.1 What You Need . . . . . . . . . . . . . . . . . . . . . 103 5.2 Measuring Distances with an Ultrasonic Sensor . . 104 5.3 Increasing Precision Using Floating-Point Numbers 110 5.4 Increasing Precision Using a Temperature Sensor . 113 5.5 Transferring Data Back to Your ComputerUsing Pro- cessing . . . . . . . . . . . . . . . . . . . . . . . . . . 119 5.6 Representing Sensor Data . . . . . . . . . . . . . . . 123 5.7 Building the Application’s Foundation . . . . . . . . 125 5.8 Implementing Serial Communication in Processing 126 5.9 Visualizing Sensor Data . . . . . . . . . . . . . . . . 128 5.10 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 131 5.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 131 Reporterratum Download from Wow! eBook <www.wowebook.com> thiscopyis(P1.0printing,Janurary,2011) CONTENTS 9 6 Building a Motion-Sensing Game Controller 132 6.1 What You Need . . . . . . . . . . . . . . . . . . . . . 133 6.2 Wiring Up the Accelerometer. . . . . . . . . . . . . . 134 6.3 Bringing Your Accelerometer to Life . . . . . . . . . 135 6.4 Finding and Polishing Edge Values . . . . . . . . . . 137 6.5 Building Your Own Game Controller . . . . . . . . . 140 6.6 Writing Your Own Game . . . . . . . . . . . . . . . . 144 6.7 More Projects . . . . . . . . . . . . . . . . . . . . . . 152 6.8 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 153 6.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 153 7 Tinkering with the Wii Nunchuk 154 7.1 What You Need . . . . . . . . . . . . . . . . . . . . . 154 7.2 Wiring a Wii Nunchuk . . . . . . . . . . . . . . . . . 155 7.3 Talking to a Nunchuk. . . . . . . . . . . . . . . . . . 156 7.4 Building a Nunchuk Class . . . . . . . . . . . . . . . 159 7.5 Using Our Nunchuk Class . . . . . . . . . . . . . . . 162 7.6 Rotating a Colorful Cube . . . . . . . . . . . . . . . . 163 7.7 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 169 7.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 169 8 Networking with Arduino 170 8.1 What You Need . . . . . . . . . . . . . . . . . . . . . 171 8.2 Using Your PC to Transfer Sensor Data to the Inter- net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 8.3 Registering an Application with Twitter . . . . . . . 174 8.4 Tweeting Messages with Processing. . . . . . . . . . 175 8.5 Networking Using an Ethernet Shield . . . . . . . . 179 8.6 Emailing from the Command Line . . . . . . . . . . 186 8.7 Emailing Directly from an Arduino . . . . . . . . . . 188 8.8 Detecting Motion Using a Passive Infrared Sensor . 192 8.9 Bringing It All Together . . . . . . . . . . . . . . . . . 196 8.10 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 199 8.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 201 9 Creating Your Own Universal Remote Control 202 9.1 What You Need . . . . . . . . . . . . . . . . . . . . . 203 9.2 Understanding Infrared Remote Controls . . . . . . 204 9.3 Grabbing Remote Control Codes . . . . . . . . . . . 205 9.4 Building Your Own Apple Remote . . . . . . . . . . . 209 9.5 Controlling Devices Remotely with Your Browser . . 212 Reporterratum Download from Wow! eBook <www.wowebook.com> thiscopyis(P1.0printing,Janurary,2011) CONTENTS 10 9.6 Building an Infrared Proxy . . . . . . . . . . . . . . . 214 9.7 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 221 9.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 222 10 Controlling Motors with Arduino 223 10.1 What You Need . . . . . . . . . . . . . . . . . . . . . 223 10.2 Introducing Motors . . . . . . . . . . . . . . . . . . . 224 10.3 First Steps with a Servo Motor . . . . . . . . . . . . 225 10.4 Building a Blaminatr . . . . . . . . . . . . . . . . . . 228 10.5 What If It Doesn’t Work? . . . . . . . . . . . . . . . . 233 10.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 234 III Appendixes 236 A Basics of Electronics 237 A.1 Current, Voltage, and Resistance . . . . . . . . . . . 237 A.2 Learning How to Solder . . . . . . . . . . . . . . . . . 241 B Advanced Arduino Programming 247 B.1 The Arduino Programming Language . . . . . . . . . 247 B.2 Bit Operations . . . . . . . . . . . . . . . . . . . . . . 249 C Advanced Serial Programming 251 C.1 Learning More About Serial Communication . . . . 251 C.2 Serial Communication Using Various Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . 253 D Bibliography 266 Index 267 Reporterratum Download from Wow! eBook <www.wowebook.com> thiscopyis(P1.0printing,Janurary,2011)

Description:
Loaded with excellent examples and references, Arduino: A Quick-Start. Guide gets .. ming course or read a beginner's book about programming first (Learn.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.