Programming Arduino: Getting Started with Sketches (Tab) Monk - The ebook in PDF/DOCX format is available for instant download
Programming Arduino: Getting Started with Sketches (Tab) Monk - The ebook in PDF/DOCX format is available for instant download
https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-third-edition-simon-monk/
https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-3rd-edition-simon-monk/
https://ebookmass.com/product/programming-arduino-next-steps-going-
further-with-sketches-2nd-edition-simon-monk/
https://ebookmass.com/product/programming-the-raspberry-pi-third-
edition-getting-started-with-python-simon-monk/
Programming the Intel Galileo: Getting Started with the
Arduino -Compatible Development Board Christopher Rush
https://ebookmass.com/product/programming-the-intel-galileo-getting-
started-with-the-arduino-compatible-development-board-christopher-
rush/
https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-rush-christopher/
https://ebookmass.com/product/programming-with-stm32-getting-started-
with-the-nucleo-board-and-c-c-donald-norris/
https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-tab-christopher-rush/
https://ebookmass.com/product/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-simon-monk/
Programming Arduino™
Getting Started with Sketches
SECOND EDITION
Simon Monk
Copyright © 2016, 2012 by McGraw-Hill Education. All rights reserved. Printed in the United
States of America. Except as permitted under the United States Copyright Act of 1976, no
part of this publication may be reproduced or distributed in any form or by any means, or
stored in a database or retrieval system, without the prior written permission of the
publisher, with the exception that the program listings may be entered, stored, and executed
in a computer system, but they may not be reproduced for publication.
McGraw-Hill Education, the McGraw-Hill Education logo, TAB, and related trade dress are
trademarks or registered trademarks of McGraw-Hill Education and/or its affiliates in the
United States and other countries and may not be used without written permission. All other
trademarks are the property of their respective owners. McGraw-Hill Education is not
associated with any product or vendor mentioned in this book.
Arduino is a trademark of Arduino LLC.
1 2 3 4 5 6 7 8 9 DOC 21 20 19 18 17 16
ISBN 978-1-25-964163-3
MHID 1-25-964163-5
Sponsoring Editor
Michael McCabe
Editorial Supervisor
Stephen M. Smith
Production Supervisor
Pamela A. Pelton
Acquisitions Coordinator
Lauren Rogers
Project Manager
Srishti Malasi,
Cenveo® Publisher Services
Copy Editor
Claire Splan
Proofreader
Cenveo Publisher Services
Indexer
Jack Lewis
Art Director, Cover
Jeff Weeks
Illustration
Cenveo Publisher Services
Composition
Cenveo Publisher Services
1 This Is Arduino
Microcontrollers
Development Boards
A Tour of an Arduino Board
Power Supply
Power Connections
Analog Inputs
Digital Connections
Microcontroller
Other Components
The Origins of Arduino
The Arduino Family
Uno and Leonardo
Mega and Due
The Micro and Small Arduino Boards
Yun
Lilypad
Other “Official” Boards
Arduino Clones and Variants
Conclusion
2 Getting Started
Powering Up
Installing the Software
Uploading Your First Sketch
The Arduino Application
Conclusion
3 C Language Basics
Programming
What Is a Programming Language?
Blink—Again!
Variables
Experiments in C
Numeric Variables and Arithmetic
Commands
if
for
while
Constants
Conclusion
4 Functions
What Is a Function?
Parameters
Global, Local, and Static Variables
Return Values
Other Variable Types
floats
boolean
Other Data Types
Coding Style
Indentation
Opening Braces
Whitespace
Comments
Conclusion
8 Data Storage
Constants
Storing Data in Flash Memory
EEPROM
Storing an int in EEPROM
Using the AVR EEPROM Library
Storing a float in EEPROM
Storing a String in EEPROM
Clearing the Contents of EEPROM
Compression
Range Compression
Conclusion
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
9 Displays
Alphanumeric LCD Displays
A USB Message Board
Using the Display
Other LCD Library Functions
OLED Graphic Displays
Connecting an OLED Display
Software
Conclusion
Index
PREFACE
The first edition of this book was published in November 2011 and
has been Amazon’s highest ranking book on Arduino.
At the time the book was originally written, the current Arduino
model was the Arduino 2009 and the software version was Beta018.
Almost at the time the book arrived in stores, the Arduino Uno and
version 1.0 of the Arduino software were released. Soon after, the
second printing of the book had a minor update to cover the new
board and software without formally being a second edition. This
edition brings the book fully up to date and is based on Arduino 1.6.
The Arduino Uno R3 is still considered to be the standard
Arduino board. However, many other boards, including both official
Arduino boards (like the Leonardo, Zero, 101, Due, and Yun) and
other Arduino programming language–based devices like the Photon
and Intel Edison, have also appeared.
This edition also addresses the use of Arduino in IoT (Internet of
Things) projects and the use of various types of display including
OLED and LCD.
Simon Monk
ACKNOWLEDGMENTS
I thank Linda for giving me the time, space, and support to write
this book and for putting up with the various messes my projects
create around the house.
Many thanks to Robert “BobKat” Logan and the many other
eagle-eyed and helpful folk who reported errata for the first edition. I
have done my best to fix what you found.
Finally, I would like to thank Michael McCabe, Srishti Malasi, and
everyone involved in the production of this book. It’s a pleasure to
work with such a great team.
INTRODUCTION
Resources
This book is supported by an accompanying website:
www.arduinobook.com
There you will find all the source code used in this book as well as
other resources, such as errata.
1
This Is Arduino
Microcontrollers
The heart of your Arduino is a microcontroller. Pretty much
everything else on the board is concerned with providing the board
with power and allowing it to communicate with your desktop
computer.
A microcontroller really is a little computer on a chip. It has
everything and more than the first home computers had. It has a
processor, a kilobyte or two of random access memory (RAM) for
holding data, a few kilobytes of erasable programmable read-only
memory (EPROM) or flash memory for holding your programs and it
has input and output pins. These input/output (I/O) pins link the
microcontroller to the rest of your electronics.
Inputs can read both digital (is the switch on or off?) and analog
(what is the voltage at a pin?). This opens up the opportunity of
connecting many different types of sensor for light, temperature,
sound, and more.
Outputs can also be analog or digital. So, you can set a pin to be
on or off (0 volts or 5 volts) and this can turn light-emitting diodes
(LEDs) on and off directly, or you can use the output to control higher
power devices such as motors. They can also provide an analog
output. That is, you can control the power output of a pin, allowing
you to control the speed of a motor or the brightness of a light, rather
than simply turning it on or off.
The microcontroller on an Arduino Uno board is the 28-pin chip
fitted into a socket at the center of the board. This single chip
contains the memory, processor, and all the electronics for the
input/output pins. It is manufactured by the company Atmel, which is
one of the major microcontroller manufacturers. Each of the
microcontroller manufacturers actually produces dozens of different
microcontrollers grouped into different families. The microcontrollers
are not all created for the benefit of electronics hobbyists like us. We
are a small part of this vast market. These devices are really
intended for embedding into consumer products, including cars,
washing machines, DVD players, children’s toys, and even air
fresheners.
The great thing about the Arduino is that it reduces this
bewildering array of choices by standardizing on one microcontroller
and sticking with it. (Well, as we see later, this statement is not quite
true, but it’s close enough.)
This means that when you are embarking on a new project, you
do not first need to weigh all the pros and cons of the various flavors
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Other documents randomly have
different content
Till then, make use of your Philosophie. [Exit.
[Exeun[t] in pomp.
Diana descends.
Diana. Honor set ope thy gates, and with thee bring
My servant and thy friend, fair Dorigen:
Let her triumph, with her, her Lord, and friend,
Who, though misled, still honor was their end.
[Flourish.
Enter the Shew of Honors Triumph; a great flourish of Trumpets and
Drums within; Then enter a noise of Trumpets sounding cheerfully.
Then follows an armed Knight bearing a Crimson Banneret in hand,
with the inscription Valour: by his side a Lady, bearing a Watchet
Banneret, the inscription Clemencie: next Martius and Sophocles
with Coronets. Next, two Lad[i]es, one bearing a white Banneret, the
inscription Chastity: the other a black, the inscription Constancie.
Then Dorigen crown'd. Last, a Chariot drawn by two Moors, in it a
Person crown'd, with a Scepter: on the top, in an antick Scutcheon,
is written Honor. As they pass over, Diana ascends.
Rinald. How like you it?
Frig. Rarely; so well, I would they would do it again. How many of
our wives now adays would deserve to triumph in such a Chariot?
Rinald. That's all one; you see they triumph in Caroches.
Frig. That they do, by the mass; but not all neither; many of them
are content with Carts. But Seignior, I have now found out a great
absurditie i'faith.
Rinald. What was 't?
Frig. The Prologue presenting four Triumphs, made but three legs to
the King: a three-legged Prologue, 't was monstrous.
Rinald. 'T had been more monstrous to have had a four-legg'd one.
Peace, the King speaks.
Isa. I, my Lord,
But that she told a lye to vex her husband;
Therein sh[e] fail'd.
Enter Dorothea.
Angel. Ghess.
Ang. And let your thoughts flee higher: aim them right;
Sir, you may hit, you have the fairest white.
Ben. Where?
Where would you catch her?
Do you know my daughter Violanta, Sir?
Enter Gerrard.
Ger. My good Lord,
My Lord, your brother craves your conference
Instantly, on affairs of high import.
Ger. Well,
Too well: my fraught of health my sickness is;
In life, I am dead; by living dying still.
Ferd. First let this Cabinet keep your pawn, and I will trust:
Yet for the form of satisfaction,
et o t e o o sat s act o ,
Take this my Oath to boot. By my presum'd
Gentrie, and sacred known Christianitie,
I'll die, ere I reveal thy trust.
Ger. Strange.
G F di d l i ld t h thi b t
Ger. Ferdinand, my love is old to her, thine new begot:
I have not wrong'd thee; think upon thine Oath.
Enter Dorothea.
Dor. O where are you? you have made a fair hand. By —— yonder is
your Aunt with my Lady; she came in, just as she was wooing your
Mistris for another; and what did me she, but out with her purse,
and shew'd all the naked truth, ifaith. Fie upon you, you should
never trust an old woman with a secret; they cannot hold; they
cannot hold so well as we, and you'ld hang 'em. First, there was
swearing and staring, then there was howling and weeping, and O
my daughter, and O my mother.
Ger. The effect, the effect.
Ger. But what's the event? lord, how thou starv'st me, Doll!
Dor. Lord how thou starv'st me, Doll? By —— I would fain see you
cry a little. Do you stand now, as if you could get a child? Come, I'll
rack you no more: This is the heart of the business: always
provided, Signior, that if it please the fates to make you a Lord, you
be not proud, nor forget your poor handmaid Doll, who was partly
accessary to the incision of this Holofernian Maidenhead.
Ger. I will forget my name first. Speak.
Dor. Then thus; My Lady knows all; her sorrow is reasonably well
digested; has vow'd to conceal it from my Lord, till delay ripen things
better; Wills you to attend her this evening at the back gate; I'll let
you in; where her own Confessor shall put you together lawfully, e'r
the child be born; which birth is very near, I can assure you: all your
charge is your vigilance; and to bring with you some trusty Nurse, to
convey the Infant out of the house.
Ger. Oh beam of comfort, take! go, tell my Lady
I pray for her as I walk: my joys so flow,
That what I speak or do, I do not know.
[Exeunt.
Dumb Shew.
Enter Violanta at one door, we[e]ping, supported by
Cornelia and a Frier; at another door, Angelina
weeping, attended by Dorothea. Violanta kneels
down for pardon. Angelina shewing remorse, takes
her up, and cheers her; so doth Cornelia. Angelina
sends Dorothea for Gerrard. Enter Gerrard with
Dorothea: Angelina and Cornelia seem to chide
him, shewing Violanta's heavy plight: Violanta
rejoyceth in him: he makes signes of sorrow,
intreating pardon: Angelina brings Gerrard and
Violanta to the Frier; he joyns them hand in hand,
takes a Ring from Gerrard, puts it on Violanta's
finger; blesseth them; Gerrard kisseth her: the Frier
takes his leave. Violanta makes shew of great pain,
is instantly conveyed in by the Women, Gerrard is
bid stay; he walks in meditation, seeming to pray.
Enter Dorothea, whispers him, sends him out.
Enter Gerrard with a Nurse blindfold; gives her a
purse. To them Enter Angelina and Cornelia with an
Infant; they present it to Gerrard; he kisseth and
blesseth it; puts it into the Nurses arms, kneels,
and takes his leave. Exeunt all severally.
Enter Benvoglio and Randulpho.
Ben. He's dead, you say then.
Ben. 'Fore Heaven 'tis true. But is Rinaldo (brother) our good Duke,
heard of living?
Rand. Living, Sir, and will be shortly with the Senate: has
Been close conceal'd at Mantua, and reliev'd:
But what's become of his? no tidings yet?
But brother, till our good Duke shall arrive,
Carry this news, here. Where's your Ferdinand?
Dor. Sure, Sir, when this was got, she had a bed-fellow.
Dor. 'T has left her, but she has had a sore fit.
Dor. So has she had, Sir. How these old fornicators talk! she had
more
Need of Mace-Ale, and Rhenish-wine Caudles, heaven knows,
Then your aged Discipline.
Ben. Say?
Enter Ferdinand.
Ang. She will have the man; and on recovery
Will wholly be dispos'd by you.
Angel. Well,
Bid him do so.
Angel. Yes.
Angel. Draw in
The bed nearer the fire: silken rest,
Tie all thy cares up. [Exeunt.
Ben. Ferdinand,
Thy steel hath digg'd the Earth, thy words my Heart.
Dumb Shew.
Enter Duke Rinaldo with Attendants, at one door;
States, Randulpho, and Gerrard, at another: they
kneel to the Duke, he accepts their obedience, and
raises them up: they prefer Gerrard to the Duke,
who entertains him: they seat the Duke in State.
Enter Benvoglio and Ferdinand: Benvoglio kneels
for justice; Ferd. seems to restrein him. Benvog.
gives the Duke a paper; Duke reads, frowns on
Gerr. shews the paper to the States, they seem
sorry, consult, cause the Guard to apprehend him;
they go off with him. Then Rand. and Benv. seem
to crave justice; Duke vows it, and exit with his
attendants. Rand. Ben. and Ferd. confer. Enter to
them Cornelia with two servants; she seems to
expostulate, Rand. in scorn, causeth her to be
thrust out poorly. Exit Rand. Benv. beckons Ferd. to
him (with much seeming passion) swears him; then
stamps with his foot. Enter Dorothea with a Cup,
weeping, she delivers it to Ferd. who with
discontent exit; and exeunt Benvoglio and
Dorothea.
Enter Violanta.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com