0% found this document useful (0 votes)
428 views

Getting Started With Arduino

tutorial
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
428 views

Getting Started With Arduino

tutorial
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 130
ie) 8) Ser ELECTRONICS Getti n g ar Started with Arduino Massimo Banzi co-founder of Arduino Make: O'REILLY makezine.com Getting Started with Arduino Massimo Banzi First Edition O'REILLY BEIJING » CAMBRIDGE + FARNHAM + KOLN +» SEBASTOPOL » TOKYO Getting Started with Arduino by Massimo Banzi Copyright @ 2009 Massimo Banzi. All rights reserved. Printed in U.S.A. Published by Make:Books, an imprint of Maker Media, a division of O'Reilly Media, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472 ‘O'Reilly books may be purchased for educational, business, ‘or sales promotional use. For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected] Print History: October 2008: First Edition Publisher: Dale Dougherty Associate Publisher: Dan Woods Executive Editor: Brian Jepson Creative Director: Daniel Carter Designer: Brian Scott Production Manager: Terry Bronson. Copy Editor: Nancy Katary Indexer: Patti Schiendelman Mustrations: Elisa Canducci The O'Reilly logo is a registered trademark of O'Reilly Media, Inc The Make: Projects series designations and related trade dress are trademarks of O'Reilly Media, Inc. The trademarks of third parties used in this work are the property of their respective ‘owners. Important Message to Our Readers: Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experi- ence. Electricity and other resources used for these projects are dangerous unless used properly and with adequate precautions, including safety gear. Some illustrative photos do net depict safety precautions or equipment, in order to show the project steps more clearly. These projects are not intended for use by children. Use of the instructions and suggestions in Getting Started with Arduino is at your own risk. O'Reilly Media, Inc. and the author disclaim all responsibility for any resulting damage, injury. expense. It is your responsibility to make sure that your activities comply with applicable laws, including copyright ISBN: 978-0-596-15551-3 (tsi) [2010-1210] Contents PrEfACE «0... cece cette eee eee eee eee eee eee eee eee v T/Introduction ..... 0.62 cece cece eee eee eee eee eee eee 1 Intended Audience oor What Is Physical Computing? 3 Fann AUCH OAT RC) LY aetna teat a tatattaetatetet eat te tate atete etre teres tetetste tate tee aeatetta 5 Prototyping 6 Tinkering Patching. Circuit Bending. . . Keyboard Hacks . . We Love Junk! Hacking Toys . Collaboration. . 3/The Arduino Platform . The Arduino Hardware The Software (IDE) : Installing Arduino on Your Computer # a ee Installing Drivers: MacintOSh 00... ccc ccc cece eee eee ee Installing Drivers: Windows Port Identification: Macintosh any 7 Port identification: WINdOWS jesiesicciiieieiieiie Cee cee cee cecce deere 4/Really Getting Started with Arduino .. Sensors and Actuators Blinking an LED. Pass Me the Parmesan Arduino |s Not for Quitters Real Tinkerers Write Comments r The Code, Step by Step ...........c cece cece ween What We Will Be Building What Is Electricity? . . Using a Pushbutton to Control the LED How Does This Work? ............++ ‘One Circuit, A Thousand Behaviours 5/Advanced Input and Output ........ 0.0 ce cece eee eens eee eee Trying Out Other On/Off Sensors Controlling Light with PWM Use a Light Sensor Instead of a Pushbutton Analogue Input... ‘Try Other Analogue Sensors Serial Communication . - Driving Bigger Loads (Motors, iarpe and the Like) ite Complex Sensors 6/Talking to the Cloud Planning. Coding Assembling the Circuit . feasheyaaunsintenaaceass .83 eres MOW. EO cS CI WIC] tne nn hehe tee EE Ee etter te tte ye] 34 7/Troubleshooting - Testing the Board. Testing Your Breadboarded Circuit. lsolating Problems... ...... Problems with the IDE. . How to Get Help Online. Appendices Appendix A/The Breadboard . Appendix B/Reading Reistors and Capacitors ............. weeee eee OS Appendix C/The Quick Reference Appendix D/Reading Schematic Diagrams . Preface A few years ago | was given a very interesting challenge: teach designers the bare minimum in electronics so that they could build inter- active prototypes of the objects they were designing. | started following a subconscious instinct to teach electronics the same way | was taught in school. Later on | realised that it simply wasn't working as well as | would like, and started to remember sitting in a class, bored like hell, listening to all that theory being thrown at me without any practical application for it. In reality, when | was in school | already knew electronics in a very empirical way: very little theory, but a lot of hands-on experience. | started thinking about the process by which | really learned electronics: » | took apart any electronic device | could put my hands on. » | slowly learned what all those components were. » | began to tinker with them, changing some of the connections inside of them and seeing what happened to the device: usually something between an explosion and a puff of smoke. » | started building some kits sold by electronics magazines ») | combined devices | had hacked, and repurposed kits and other circuits that | found in magazines to make them do new things. As alittle kid, | was always fascinated by discovering how things work; therefore, | used to take them apart. This passion grew as | targeted any unused object in the house and then took it apart into small bits. Even- tually, people brought all sorts of devices for me to dissect. My biggest Preface v projects at the time were a dishwasher and an early computer that came from an insurance office, which had a huge printer, electronics cards, magnetic card readers, and many other parts that proved very interesting and challenging to completely take apart. After quite a lot of this dissecting, | knew what electronic components were and roughly what they did. On top of that, my house was full of old electronics magazines that my father must have bought at the beginning of the 1970s. | spent hours reading the articles and looking at the circuit diagrams without understanding very much. This process of reading the articles over and over, with the benefit of knowledge acquired while taking apart circuits, created a slow virtuous circle. A great breakthrough came one Christmas, when my dad gave mea kit that allowed teenagers to learn about electronics. Every component was housed in a plastic cube that would magnetically snap together with other cubes, establishing a connection; the electronic symbol was written on top. Little did | know that the toy was also a landmark of German design, because Dieter Rams designed it back in the 1960s. With this new tool, | could quickly put together circuits and try them out to see what happened. The prototyping cycle was getting shorter and shorter. After that, | built radios, amplifiers, circuits that would produce horrible noises and nice sounds, rain sensors, and tiny robots. I've spent a long time looking for an English word that would sum up that way of working without a specific plan, starting with one idea and ending up with a completely unexpected result. Finally, “tinkering” came along. | recognised how this word has been used in many other fields to describe a way of operating and to portray people who set out on a path of explora- tion. For example, the generation of French directors who gave birth to the “Nouvelle Vague” were called the “tinkerers”. The best definition of tinkering that I've ever found comes from an exhibition held at the Exploratorium in San Francisco: Tinkering is what happens when you try something you don’t quite know how to do, guided by whim, imagination, and curiosity. When you tinker, there are no instructions—but there are also no failures, no right or wrong ways of doing things. It’s about figuring out how things work and reworking them. vi Getting Started with Arduino Contraptions, machines, wildly mismatched objects working in harmony— this is the stuff of tinkering. Tinkering is, at its most basic, a process that marries play and inquiry. —www.exploratorium.edu/tinkering From my early experiments | knew how much experience you would need inorder to be able to create a circuit that would do what you wanted start- ing from the basic components. Another breakthrough came in the summer of 1982, when | went to London with my parents and spent many hours visiting the Science Museum. They had just opened a new wing dedicated to computers, and by follow- ing a series of guided experiments, | learned the basics of binary math and programming. There | realised that in many applications, engineers were no longer build- ing circuits from basic components, but were instead implementing a lot of the intelligence in their products using microprocessors. Software was replacing many hours of electronic design, and would allow a shorter tinkering cycle. When I came back | started to save money, because | wanted to buy a computer and learn how to program. My first and most important project after that was using my brand-new ZX81 computer to control a welding machine. | know it doesn't sound like avery exciting project, but there was a need for it and it was a great chal- lenge for me, because | had just learned how to program. At this point, it became clear that writing lines of code would take less time than modify- ing complex circuits. Twenty-odd years later, I'd like to think that this experience allows me to teach people who don’t even remember taking any math class and to infuse them with the same enthusiasm and ability to tinker that | had in my youth and have kept ever since —Massimo Preface vii

You might also like