Norman Dunbar
Arduino Software Internals
A Complete Guide to How Your Arduino Language and Hardware Work Together
Norman Dunbar
Rawdon, West Yorkshire, UK
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-5789-0 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5789-0 e-ISBN 978-1-4842-5790-6
https://doi.org/10.1007/978-1-4842-5790-6
Norman Dunbar 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
This book is dedicated to my wife, Alison, who sometimes allows me to have some time to myself, programming, attempting to build things (with or without Internet of), and writing notes, articles, and/or this book.
Another person, to whom I am grateful, is Alisons late maternal grandmother, Minnie Trees (yes, I did call her Bonsai!), who gifted me an Arduino Duemilanove starter kit and rekindled my long-lost (for over 35 years) interest in building things with electronics.
The book is also dedicated to the myriad of people and companies or organizations around the world who freely give their time and skills to produce open source software and hardware, for the benefit of others or just for fun.
If I may paraphrase the words of Isaac Newton, I too stand on the shoulders of giants, so heres to the giants, the little people, and all the medium-sized ones too, who may or may not become giants themselves. Lets hope the fun never stops.
Finally, my own motto isDont think! Find out!Hopefully this book will help you do exactly that.
Preface
If I have seen further it is by standing on ye sholders of Giants.
Sir Isaac Newton (16431727), Letter to Robert Hooke
There are many books which discuss the abilities of the Arduinohardwareand how best the maker can use this to their benefit. I have many of them in my bookcase, and digital versions on my phone and tablet in case I get bored with life and need something interesting to read. Many of these books explain what the hardware does; and some even dig deeper into the hardware to explain how, in fairly easy to understand terms, it does it.
There are no books which take a similar view of the Arduinosoftware. There is now! This book takes you on ajourney(why do wealwayshave to be on a journey these days?) into the world of Arduino sketches and the various files involved in the compilation process. It will delve deep into the supplied software and look at the specific parts of the Arduino Language which deal with the underlying hardware, the ATmega328P (or ATmega328AU) microcontrollers henceforth referred to as ATmega328P.
Once the Arduino Language has been explained, the book takes a short look at how you can strip away the Arduinohand holdingand get down and dirty with the naked hardware. Its not easy, but equally its not too difficult. Dont worry, this is still the C/C++ language, theres no assembly language required. Perhaps!
Table of Contents
About the Author
Norman Dunbar
is an Oracle database administrator. Norman has had a long-running relationship with electronics since childhood and computers since the late 1970s, and the Arduino was a perfect marriage of the two interests. With a love of learning new things, examining and explaining the Arduino Language and the hardware became a bit of a hobby, and as piles of notes expanded, Norman has now decided to publish his work.
About the Technical Reviewer
Sai Yamanoor
is an embedded systems engineer working for an industrial gases company in Buffalo, New York. His interests, deeply rooted in DIY and open source hardware, include developing gadgets that aid behavior modification. He has published two books with his brother, and in his spare time, he likes to contribute to build things that improve quality of life. You can find his project portfolio at http://saiyamanoor.com .
Norman Dunbar 2020
N. Dunbar Arduino Software Internals https://doi.org/10.1007/978-1-4842-5790-6_1
1. Introduction
Norman Dunbar
(1)
Rawdon, West Yorkshire, UK
The Arduino is a great system for getting people into making with electronics and microcontrollers. I was reintroduced to a long-lost hobby when I was gifted an Arduino Duemilanove (aka 2009) by my wifes late grandmother, and since then, Ive had lots of fun learning and attempting to build things. Ive even built a number of Arduino clones based on just the AVR microcontroller and a few passive components its cheaper than fitting a new Arduino into a project!
Much has changed over the intervening years. LEDs used to cost about 10 each and came in one color, red. These days I can get a pack of 100 LEDs for about 2 in various different colors. Even better, my old faithful Antex 15W soldering iron still worked, even after 35 years.
The Arduino, and Im concentrating on either the Uno version 3 or the Duemilanove here, as those are two of the ones Ive actually purchased (or been given), is based on an Atmel ATmega328 microcontroller. On the Uno its the Atmel ATmega328P-AU, while the Duemilanove uses the ATmega328P-PU.
Roughly, the only difference between the two is the UNOs AU version is a surface mount, while the PU version is a 28-pin through-hole device. They are/should be identical to program, although the AU version does have two additional analogue pins that are not present on the ATmega328P-PU.