Professional Documents
Culture Documents
Programming Arduino: Getting Started with Sketches, Third Edition Simon Monk full chapter instant download
Programming Arduino: Getting Started with Sketches, Third Edition Simon Monk full chapter instant download
https://ebookmass.com/product/programming-arduino-getting-
started-with-sketches-3rd-edition-simon-monk/
https://ebookmass.com/product/programming-arduino-getting-
started-with-sketches-tab-monk/
https://ebookmass.com/product/programming-the-raspberry-pi-third-
edition-getting-started-with-python-simon-monk/
https://ebookmass.com/product/programming-arduino-next-steps-
going-further-with-sketches-2nd-edition-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/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-simon-monk/
https://ebookmass.com/product/getting-started-with-sql-and-
databases-managing-and-manipulating-data-with-sql-mark-simon/
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/
Copyright © 2023, 2016, 2012 by McGraw Hill. All rights reserved.
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.
ISBN: 978-1-26-467888-4
MHID: 1-26-467888-6
The material in this eBook also appears in the print version of this
title: ISBN: 978-1-26-467698-9, MHID: 1-26-467698-0.
TERMS OF USE
This is a copyrighted work and McGraw-Hill Education and its
licensors reserve all rights in and to the work. Use of this work is
subject to these terms. Except as permitted under the Copyright Act
of 1976 and the right to store and retrieve one copy of the work,
you may not decompile, disassemble, reverse engineer, reproduce,
modify, create derivative works based upon, transmit, distribute,
disseminate, sell, publish or sublicense the work or any part of it
without McGraw-Hill Education’s prior consent. You may use the
work for your own noncommercial and personal use; any other use
of the work is strictly prohibited. Your right to use the work may be
terminated if you fail to comply with these terms.
Preface
Acknowledgments
Introduction
1 Getting Started
Microcontrollers
Development Boards
A Tour of an Arduino Uno Board
Power Supply
Power Connections
Analog Inputs
Digital Connections
Microcontroller
Other Components
A Tour of a WiFi-Capable Arduino-Compatible
The Origins of Arduino
Powering Up
Installing the Software
Uploading Your First Sketch
The Arduino Application
Conclusion
2 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
3 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
6 Boards
Arduino Nano
Arduino Pro Mini
Breadboard
The Boards Manager
ESP32 Boards
Raspberry Pi Pico
BBC micro:bit
Adafruit Feather System
Conclusion
7 Advanced Arduino
Random Numbers
Math Functions
Bit Manipulation
Advanced I/O
Generating Tones
Feeding Shift Registers
Interrupts
Compile-Time Constants
The Arduino Web Editor
Conclusion
8 Data Storage
Large Data Structures
Storing Data in Flash Memory
EEPROM
Storing an int in EEPROM
Writing Anything to EEPROM
Storing a float in EEPROM
Storing a String in EEPROM
Clearing the Contents of EEPROM
Compression
Range Compression
Conclusion
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.
The Arduino Uno is still considered to be the standard Arduino
board. However, many other boards, including both official Arduino
boards (like the Leonardo, Nano, and Pro Mini) and other Arduino-
compatible devices like the Raspberry Pi Pico, ESP32-based boards,
and numerous Feather boards from Adafruit have also appeared.
The Arduino software is available for so many families of
microcontroller, that it has become the environment of choice for
many embedded programmers.
This edition also addresses the use of Arduino in Internet of
Things (IoT) 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.
Finally, I would like to thank Lara Zoble 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 web page.
www.arduinobook.com
There you will find all the source code used in this book as well as
other resources, such as errata.
1
Getting Started
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 small amount of random access memory (RAM) for
holding data, some 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 Microchip,
which is one of the major microcontroller manufacturers. Each of the
microcontroller manufacturers 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, TVs, cars, children’s toys, and even air
fresheners.
The Arduino system provides a standardized way of programming
all manner of microcontrollers and is not limited to official Arduino
boards. This means that whatever microcontroller you want to use,
you can (with a few exceptions) program it as an Arduino without
having to learn some manufacturer’s proprietary software tool.
Another random document with
no related content on Scribd:
Cross-head Designed by Mr. Porter.
Contract with Ormerod, Grierson & Co. Engine for Evan Leigh, Son & Co. Engine
for the Oporto Exhibition. Getting Home from Portugal.
Trouble with the Evan Leigh Engine. Gear Patterns from the Whitworth Works.
First Order for a Governor. Introduction of the Governor into Cotton Mills.
Invention of my Condenser. Failure of Ormerod, Grierson & Co.
Diagrams from Engine of Evan Leigh, Son & Co. Sixteen Pounds to the Inch.
And, after all, the fault was largely mine. I did not think of it till long
afterwards, and it did not occur to anybody else, not even to those
most deeply interested in the boiler. My surface condenser was the
cause of all the trouble, and that was why I have to this day deeply
regretted having put it in. The oil used in the cylinder was all sent