10723Essentials of Arduino™ Boards Programming: Step-by-Step Guide to Master Arduino Boards Hardware and Software 1st Edition Farzin Asadi - Download the full ebook set with all chapters in PDF format
10723Essentials of Arduino™ Boards Programming: Step-by-Step Guide to Master Arduino Boards Hardware and Software 1st Edition Farzin Asadi - Download the full ebook set with all chapters in PDF format
com
https://ebookmeta.com/product/essentials-of-arduino-boards-
programming-step-by-step-guide-to-master-arduino-boards-
hardware-and-software-1st-edition-farzin-asadi/
OR CLICK HERE
DOWLOAD EBOOK
Farzin Asadi
Essentials of Arduino™ Boards Programming: Step-by-Step Guide to Master
Arduino Boards Hardware and Software
Farzin Asadi
Department of Electrical and Electronics Engineering, Maltepe University,
Istanbul, Türkiye
ISBN-13 (pbk): 978-1-4842-9599-1 ISBN-13 (electronic): 978-1-4842-9600-4
https://doi.org/10.1007/978-1-4842-9600-4
Copyright © 2023 by Farzin Asadi
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.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Miriam Haidara
Development Editor: James Markham
Coordinating Editor: Jessica Vakili
Cover image designed by eStudioCalamar
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY
10004, U.S.A. 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.
For information on translations, please e-mail booktranslations@springernature.com; for
reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on GitHub (https://github.com/Apress). For more detailed information,
please visit http://www.apress.com/source-code.
Paper in this product is recyclable
Dedicated to my lovely brother, Farzad, and my lovely
sisters, Farnaz and Farzaneh.
Table of Contents
About the Author�������������������������������������������������������������������������������xiii
Introduction��������������������������������������������������������������������������������������xvii
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Index�������������������������������������������������������������������������������������������������327
xii
About the Author
Farzin Asadi received his BSc in Electronics
Engineering, MSc in Control Engineering, and
PhD in Mechatronics Engineering.
Currently, he is with the Department of
Electrical and Electronics Engineering at
Maltepe University, Istanbul, Turkey.
Dr. Asadi has published more than 40 papers
in ISI/Scopus indexed journals. He has written 25
books. His research interests include switching
converters, control theory, robust control of
power electronics converters, and robotics.
xiii
About the Technical Reviewer
Hai Van Pham received his BSc, MSc, and PhD
in Computer Science.
Currently, he is with the School of
Information and Communication Technology,
Hanoi University of Science and Technology,
Hanoi, Vietnam.
Dr. Pham has published over 100 papers in
ISI/Scopus indexed journals. He is an associate
editor in domestic and international journals
and served as chair and technical committee
member of many national and international
conferences including SOICT 2014, KSE 2015, KSE 2017, KSE 2019, KSE
2021, and KSE 2022.
His research interests include artificial intelligence, knowledge-based
systems, big data, soft computing, rule-based systems, and fuzzy systems.
xv
Introduction
Arduino is an open source hardware and software company, project,
and user community that designs and manufactures single-board
microcontrollers and microcontroller kits for building digital devices.
Arduino boards use a variety of microcontrollers, and each board is
suitable for a specific application. For instance, Arduino Nano or Pro Mini
is an ideal option if space or weight is important for you. If you search for
a board with many input/output (I/O) pins, then Arduino MEGA is a good
option for you. If you need an Arduino board for a time-critical application
like a robot control, then Arduino DUE is a good choice. Arduino UNO is a
good option for educational purposes. All of the examples in this book are
done with Arduino UNO.
There exist many other development boards in the world, but why are
Arduino boards so famous with millions of users? Here are some of the
basic reasons that make Arduino boards outstanding:
xvii
Introduction
xviii
Introduction
xix
CHAPTER 1
Introduction
to Arduino Boards
1.1 Introduction
Arduino is an open source platform used for building electronics projects.
Arduino consists of both a physical programmable circuit board (often
referred to as a microcontroller) and a piece of software or IDE (Integrated
Development Environment) that runs on your computer, used to write and
upload computer code to the physical board.
The Arduino platform has become quite popular with people just
starting out with electronics, and for good reason. Unlike most previous
programmable circuit boards, the Arduino does not need a separate piece
of hardware (called a programmer) in order to load new code onto the
board; you can simply use a USB cable. Additionally, the Arduino IDE uses
a simplified version of C++, making it easier to learn to program. Finally,
Arduino provides a standard form factor that breaks out the functions of
the microcontroller into a more accessible package.
This chapter is an introduction to microcontrollers and Arduino
boards and makes the foundation for other chapters.
1.2 Microcontrollers
A microcontroller is a compact integrated circuit designed to govern a specific
operation in an embedded system. A typical microcontroller includes a
processor, memory, and input/output (I/O) peripherals on a single chip.
Some of the commonly used microcontrollers are shown in Figures 1-1 to 1-3.
3
Chapter 1 Introduction to Arduino Boards
1.3 Elements of a Microcontroller
The core elements of a microcontroller are
4
Chapter 1 Introduction to Arduino Boards
While the processor, memory, and I/O peripherals are the defining
elements of the microprocessor, there are other elements that are
frequently included. The term I/O peripherals itself simply refers to
supporting components that interface with the memory and processor.
There are many supporting components that can be classified as
peripherals. Having some manifestation of an I/O peripheral is elemental
to a microprocessor, because they are the mechanism through which the
processor is applied.
Other supporting elements of a microcontroller include
5
Chapter 1 Introduction to Arduino Boards
1.5 Arduino Boards
In a nutshell, an Arduino (/ɑːrˈdwiːnoʊ/) is an open hardware development
board that can be used by tinkerers, hobbyists, and makers to design and
build devices that interact with the real world.
The Arduino hardware and software were designed for artists,
designers, hobbyists, hackers, newbies, and anyone interested in creating
interactive objects or environments. Arduino can interact with buttons,
LEDs, motors, speakers, GPS units, cameras, the Internet, and even your
smartphone or your TV! This flexibility combined with the fact that the
Arduino software is free, the hardware boards are pretty cheap, and both
6
Chapter 1 Introduction to Arduino Boards
the software and hardware are easy to learn has led to a large community
of users who have contributed code and released instructions for a huge
variety of Arduino-based projects.
Most Arduino boards use Atmel 8-bit microcontrollers (ATmega8,
ATmega168, ATmega328, ATmega1280, or ATmega2560). Some Arduino
boards use ARM Cortex–based microcontrollers.
Some of the commonly used Arduino boards are shown in
Figures 1-4 to 1-6.
7
Chapter 1 Introduction to Arduino Boards
8
Chapter 1 Introduction to Arduino Boards
All of the experiments of this book are done with the aid of the
Arduino UNO board (Figure 1-4). Arduino UNO uses the ATmega328
microcontroller made by ATMEL. ATmega328 is made in different
packages (Figures 1-7 and 1-8).
9
Chapter 1 Introduction to Arduino Boards
10
Chapter 1 Introduction to Arduino Boards
11
Chapter 1 Introduction to Arduino Boards
Programs written using the Arduino IDE are called sketches. These
sketches are written in the text editor and are saved with the file .ino
extension.
As shown in Figure 1-10, the C code has two default functions: setup
and loop. The code inside the void setup will be executed once, and only
once, at the beginning of the program. Then, the code inside the void loop
will be executed again and again (hence the name “loop”), until you power
off the Arduino board.
12
Chapter 1 Introduction to Arduino Boards
1.8 HEX File
A HEX file is a hexadecimal source file typically used in the programming
of microcontrollers. If you share a .INO file, anyone can edit or see the
main program. But HEX files are much more secure than INO files; no one
can edit them because of the hexadecimal format.
Let’s see how we can see the generated HEX file associated with a C
code. Open the Arduino IDE (Figure 1-12).
13
Chapter 1 Introduction to Arduino Boards
Write the code shown in Figure 1-13. This code turns on the onboard
LED, waits for 1 s, turns off the onboard LED, waits for 1 s, and repeats this
procedure.
14
Chapter 1 Introduction to Arduino Boards
Click File ➤ Save or press Ctrl+S. This opens the Save sketch folder as…
window for you (Figure 1-14). Save the file with the name of blink.
15
Chapter 1 Introduction to Arduino Boards
16
Chapter 1 Introduction to Arduino Boards
17
Chapter 1 Introduction to Arduino Boards
Click the Verify button (Figure 1-17). Wait until “Done compiling”
appears on the screen (Figure 1-18).
18
Chapter 1 Introduction to Arduino Boards
19
Chapter 1 Introduction to Arduino Boards
You can use Notepad++ to open the HEX file (Figure 1-20). As the
name suggests, it contains a collection of HEX numbers.
Now write your code and save it (Figure 1-23). Then click the Upload
button (Figure 1-24) to upload the code into the Arduino board.
22
Chapter 1 Introduction to Arduino Boards
23
Random documents with unrelated
content Scribd suggests to you:
said to be among his kinsmen at Wardak; the next that he is stirring
up the Zurmut people east of Ghazni; and then come all sorts of
absurd rumours about his being on the way to Kohistan to see what
Mir Butcha is doing.
Our intelligence department is growing at last to be something
more than a name. Before the events of the 11th and 23rd
December, the only reports that were received as trustworthy were
those given by paid spies and followers of the sirdars—followers who
are, as a rule, of the purest type of ruffianism. One always looks
upon a sirdar as a past-master in the art of deception, who would
sacrifice the British at any moment if he could do so with impunity;
and the hangers-on of these chiefs are not a whit better than their
masters. The action of the 11th in the Chardeh Valley proved to
demonstration that no trust could be placed in the reports given by
the sirdars: there were found to be 10,000 or 15,000 men within ten
miles of Sherpur, whereas we had only heard of 5,000 being at
Argandeh. Now there has been established a regular system of
patrols, and a certain number of Kizilbash horsemen are stationed at
various points on the Argandeh Kotal, Surkh Kotal, the Kohistan
Road northwards over the Paen Minar Kotal, and about Charasia.
They are under the command of one responsible native leader in
Sherpur, who again is directly controlled by Lieutenant-Colonel
Lockhart, the Quartermaster-General of the division. As these
horsemen are paid, not by results, but for regular service on patrol
work, they are likely to be more trustworthy than the highly-paid
spies hitherto employed. If the system could be a little more
extended on the lines I have before pointed out in previous letters—
viz., regular establishment—it might be a great aid to us in the
guerilla warfare we are engaged in.
Important news has been received that Abdur Rahman Khan has
left Tashkend, and is now probably in Turkistan. If his residence
among the Russians has not thoroughly converted him to their
views, he might be a useful man for us to take up. He is ambitious,
and, if we can trust Mr. Schuyler’s estimate of him, has some ability
which might now be turned to good use. What his influence would
be now in the country after so many years of absence we cannot
tell; but to-day, in mentioning his name to an old Cabuli, and saying
that he was possibly already in Turkistan, my listener’s face lighted
up with pleasure, and he eagerly asked if he would return to Cabul.
There are so many possibilities to be weighed in calculating the
chances of settling affairs here on a fairly safe basis, that Abdur
Rahman’s claims may come to be considered. Unless, as I have said,
he has been Russianised, he might fall in with our views, and, at
least as a provincial governor, be trusted with authority.
In the meantime we are making preparations to hold Cabul as well
as Sherpur in case of an attempted repetition of the events of
December 11th to 23rd. General Charles Gough’s brigade in the Bala
Hissar is busy at work, cutting a broad road from the Shah Shehr
Gate (that facing Siah Sung) to the gate overlooking the city near
Chandaul. The broken places in the walls have been built up, and
improvements made by the Engineers, so as to give shelter to the
garrison if an attack were attempted from the city. The Sherderwaza
Heights immediately above the Bala Hissar are also to be held in
future by one battalion (say 500 or 600 men), stationed in three
strong towers, now in course of construction. The first and strongest
of these is on the spur above the Arsenal; a steep point completely
commanding the Upper Bala Hissar already being crowned with
strong walls, the basement of the tower. The crest of the
Sherderwaza Heights already boasts of a strong wall, part of the
Afghan fortifications; and this position is naturally so strong, the
hillside sloping down almost perpendicularly towards Chardeh Valley,
that with the two towers now being built it could defy assault from
any force destitute of artillery. The ridge running down westwards to
the Cabul gorge would also be held if an enemy menaced the city,
and on the Asmai Heights on the northern side a strong fort is to be
built. The military roads converging upon Dehmazung from Sherpur
cantonments unite in Deh-i-Afghan and pass by the foot of the
Asmai Hill, whence they are to be continued in one broad road until
the main Bamian Road through Chardeh Valley is gained. The towers
above mentioned are to be provisioned and watered, always, for ten
days, and are to contain small-arm ammunition equal to the
requirements of a battalion for that period, calculated on the basis of
serious fighting. A road broad enough for guns will also be made
about Cabul itself from Deh-i-Afghan to the Bala Hissar, in addition
to a circular road about Sherpur cantonments. Another road is to be
cut from Bemaru village to the Siah Sung Heights, with a bridge
spanning the Cabul river; and yet another from the 67th Gateway
(near the south-eastern bastion) direct to the Bala Hissar, this also
crossing the river by a new pile bridge. These two roads will ensure
communication between Sherpur and the fortress without our troops
having to pass near the city walls; and will give us alternative
bridges over the Cabul, whereas we formerly had only one bridge,
that on the city road from Sherpur. With regard to the cantonment
itself, the clear space for 1,000 yards about the walls is already
partly made, although the débris of forts and villages destroyed
requires much levelling before it can be said that all cover has been
swept away. The blocks of solid mud and the loose rubbish could be
utilized by skirmishers advancing to attack, and until this
accumulation of ruins has been thoroughly levelled, our rifle-fire will
not have a fair chance. On the eastern point of the Bemaru Heights
a very strong tower is now being rapidly built, and the hill about it is
to be scarped for ten yards, so that to assault it from outside
cantonments would be impossible. At the north-west corner, below
the western end of Bemaru Heights, the line of trenches with their
parapet of gun-carriage wheels (described in one of my letters
written during the siege) will also be strengthened by a broad and
deep wet ditch.
CHAPTER XXII.
Philanthropic Work in Cabul—Dr. Owen’s Hospital—Prejudices gradually Overcome
—The Attendance of Women—The Hospital Wrecked by Fanatics—The Place
Re-established—A Visit to the Wards—Gratitude of the Patients—Treatment of
Men Wounded in Action—Confidence in the Surgeon’s Skill—Life in Sherpur—
Freedom of Criticism upon Current Events—The Sherpur Club—Amusements
of the Garrison—The First Theatre—The Pleasures of Skating and Sliding—A
Snow Fight on Bemaru Heights—“How they Live in Cabul”—Zenana Life—
Prevalence of Intrigues—Shopping—A Cabul Interior—A Lady’s Dress—Cabuli
Children—Character of the Citizens of Cabul—The Sirdar—Ambition and
Sensuality—A Sirdar’s House—The Rites of Hospitality—The Cabul Trader—His
Manner of doing Business.