Arduino: A Technical Reference
by J. M. Hughes
Copyright 2016 John Hughes. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Dawn Schanafelt
- Production Editor: Colleen Lobner
- Copyeditor: Rachel Head
- Proofreader: Kim Cofer
- Indexer: Ellen Troutman-Zaig
- Interior Designer: David Futato
- Cover Designer: Randy Comer
- Illustrator: John M. Hughes
and Rebecca Demarest
Revision History for the First Edition
- 2016-05-05: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491921760 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Arduino: A Technical Reference, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-92176-0
[LSI]
Preface
Since its introduction in 2005 the Arduino has become one of the most successful(some might argue the most successful) open source hardware projects in the world.Boards based on the open designs released by the Arduino team have been fabricatedin countries around the world, including Italy, Brazil, China, the Netherlands, India,and the United States. One can purchase a fully functional Arduino-compatible boardfor around $15, and the Arduino development environment is readily available fordownload and is completely free. Originally based on the 8-bit AVR family ofmicrocontrollers (the AVR is itself an interesting device with an equally interestinghistory), the Arduino has moved into the realm of 32-bit processing with the additionof the Due model with an ARM processor, the Yn with an on-board module running theOpenWrt version of Linux, and the upcoming Zero model. Arduinos have beenused for everything from interactive art to robotics, and from environmental sensorsto the smarts in small CubeSat satellites built by small teams and launched for afraction of what a full-size satellite would cost.
I bought my first Arduino (a Duemilanove) many years ago, more out of curiosity thananything else. I had worked with microprocessor and microcontroller developmentsystems since the early 1980s, starting with the 6502, 6800, and 8051, and thenmoving on to the 8086, the Z80, the 80186, and the 68000 family. Early on I usuallyprogrammed these devices in assembly language or PL/M, since these were really theonly rational choices at the time for embedded systems. Later it became feasible touse C or Ada, as the capabilities of the microprocessors improved and the softwaretools matured. In each case, however, I came to expect having loads of referencematerial available: datasheets, hefty manuals, handbooks, and reference designdocumentation that would arrive along with the development circuit board and itsaccessories. It usually showed up in a large, heavy box.
When my new Arduino arrived and I opened the very small box I found that there wasonly a circuit board, a plug-in power pack, a few LEDs and resistors, some jumperwires, and a solderless breadboard block. No manuals, no handbooks, and no datasheets. Not even a CD with documents and software on it. Nothing more than a fewsheets of paper with a manifest of what was in the box and a URL to a web page whereI could read some how to get started material and find links to the software Ineeded. I was, to say the least, surprised.
I was also ignorant. When I bought the Arduino I didnt know its full backstory, norwas I aware of its intended audience. It turns out that it was originally meantprimarily for people with little or no hardcore technical background who just wantedto experiment (in a playful sense) with something cool and make things go. In otherwords, artists and tinkerers, not engineers who have a penchant for technical detailsand an addiction to project plans, specifications, and, of course, manuals.
Once I understood this, it all made a lot more sense. Reading Massimo Banzis book Getting Started with Arduino (OReilly) gave me a better understanding of the Arduinophilosophy, and it was a good starting place in my quest for additional details. Also,unlike semiconductor manufacturers with their development kits, the folks on the Arduino team arent in the business of selling chipstheyre working to inspire creativity. TheAVR microcontroller was chosen because it was inexpensive and it could be easilyintegrated into their vision for a device that could be readily applied to a creativeendeavor. The AVR has enough computational horsepower and sufficient built-inmemory to do complex and interesting things, unlike earlier generations ofmicrocontrollers that usually needed expensive development tools and providedonly scant amounts of internal on-chip memory.
Simplicity and low cost aside, the real secret to the success of the Arduino is thefirmware bootloader on the AVR chip, coupled with a simple and easy-to-use integrateddevelopment environment (IDE) and the code libraries supplied with itall providedfree under open source and Creative Commons licensing. The Arduino philosophy is tomake it as easy as possible to use an Arduino. By clearing away the bulk of the technicaldetails and simplifying the development process, the Arduino invites the user toexperiment, try new things, and yes, play. For the first time in a long time I foundmyself actually having a lot of fun just connecting things in different combinationsto see what I could make it do. I wish that the Arduino had been around when I wasteaching introductory embedded systems designit would have helped reduce a lotof frustration for the people in the class trying to wade through assembly languagelistings, memory maps, and flowcharts.
Since my first Arduino arrived Ive found many sources for useful and interestingadd-on components for the Arduino family, some of them quite amazing in termsof both price and capabilities. In fact, I became something of an Arduino pack rat,buying inexpensive shields and modules and building up a sizable collection of variousbits. But, sadly, I have to say that many times Ive opened a package with a nifty newgizmo in it, only to discover that there is no documentation of any kind. Not even asimple wiring diagram.
As an engineer, it is particularly frustrating to me to purchase something interesting,only to have it show up with no documentation. I then have to embark on a quest todetermine if any documentation actually does exist, and in a form that I can read (Icant read Chinese). Sometimes that search is fruitless, and Im forced to resort tocomponent datasheets and reverse engineering the circuit board to figure out thewiring. Other times the information Im seeking does exist, but it is scattered acrossmultiple websites in various bits and pieces. This situation is slowly improving, butit can still be a real pain. After years of collecting stacks of notes, web page links, and datasheets, I finally decided to get organized and assemble it in one place.