100% found this document useful (3 votes)
241 views

Instant ebooks textbook Microcontroller Prototypes with Arduino and a 3D Printer Dimosthenis E. Bolanakis download all chapters

Dimosthenis

Uploaded by

labergorakle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
241 views

Instant ebooks textbook Microcontroller Prototypes with Arduino and a 3D Printer Dimosthenis E. Bolanakis download all chapters

Dimosthenis

Uploaded by

labergorakle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Download Full Version ebookmass - Visit ebookmass.

com

Microcontroller Prototypes with Arduino and a 3D


Printer Dimosthenis E. Bolanakis

https://ebookmass.com/product/microcontroller-prototypes-
with-arduino-and-a-3d-printer-dimosthenis-e-bolanakis/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Programming Arduino: Getting Started with Sketches (Tab)


Monk

https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-tab-monk/

ebookmass.com

ESP32 Formats and Communication: Application of


Communication Protocols with ESP32 Microcontroller Neil
Cameron
https://ebookmass.com/product/esp32-formats-and-communication-
application-of-communication-protocols-with-esp32-microcontroller-
neil-cameron/
ebookmass.com

Essentials of coordination chemistry - a simplified


approach with 3d visual Bhatt

https://ebookmass.com/product/essentials-of-coordination-chemistry-a-
simplified-approach-with-3d-visual-bhatt/

ebookmass.com

Advancing Multicultural Dialogues in Education 1st Edition


Richard Race (Eds.)

https://ebookmass.com/product/advancing-multicultural-dialogues-in-
education-1st-edition-richard-race-eds/

ebookmass.com
The impact of China’s One Belt One Road initiative
on international trade in the ASEAN region Nam Foo & Hooi
Hooi Lean & Ruhul Salim
https://ebookmass.com/product/the-impact-of-chinas-one-belt-one-road-
initiative-on-international-trade-in-the-asean-region-nam-foo-hooi-
hooi-lean-ruhul-salim/
ebookmass.com

Unravelling Long COVID Don Goldenberg

https://ebookmass.com/product/unravelling-long-covid-don-goldenberg/

ebookmass.com

The Surgeon Karl Hill

https://ebookmass.com/product/the-surgeon-karl-hill/

ebookmass.com

Sondheim in Our Time and His W. Anthony Sheppard (Editor)

https://ebookmass.com/product/sondheim-in-our-time-and-his-w-anthony-
sheppard-editor/

ebookmass.com

Advances in Infrastructure Finance Raghu Dharmapuri


Tirumala

https://ebookmass.com/product/advances-in-infrastructure-finance-
raghu-dharmapuri-tirumala/

ebookmass.com
Apache Lament Patrick Dearen

https://ebookmass.com/product/apache-lament-patrick-dearen/

ebookmass.com
Microcontroller Prototypes with
Arduino and a 3D Printer
Microcontroller Prototypes with
Arduino and a 3D Printer

Learn, Program, Manufacture

Dimosthenis E. Bolanakis

Department of Air Force Science


Hellenic Air Force Academy
Athens
Greece
This edition first published 2021
© 2021 John Wiley & Sons Ltd

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise,
except as permitted by law. Advice on how to obtain permission to reuse material from this title is available
at http://www.wiley.com/go/permissions.

The right of Dimosthenis E. Bolanakis to be identified as the author of this work has been asserted in
accordance with law.

Registered Offices
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, USA
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, UK

Editorial Office
The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, UK

For details of our global editorial offices, customer services, and more information about Wiley products
visit us at www.wiley.com.

Wiley also publishes its books in a variety of electronic formats and by print-on-demand. Some content
that appears in standard print versions of this book may not be available in other formats.

Limit of Liability/Disclaimer of Warranty


In view of ongoing research, equipment modifications, changes in governmental regulations, and the
constant flow of information relating to the use of experimental reagents, equipment, and devices, the
reader is urged to review and evaluate the information provided in the package insert or instructions
for each chemical, piece of equipment, reagent, or device for, among other things, any changes in the
instructions or indication of usage and for added warnings and precautions. While the publisher and
authors have used their best efforts in preparing this work, they make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties,
including without limitation any implied warranties of merchantability or fitness for a particular purpose.
No warranty may be created or extended by sales representatives, written sales materials or promotional
statements for this work. The fact that an organization, website, or product is referred to in this work as
a citation and/or potential source of further information does not mean that the publisher and authors
endorse the information or services the organization, website, or product may provide or recommendations
it may make. This work is sold with the understanding that the publisher is not engaged in rendering
professional services. The advice and strategies contained herein may not be suitable for your situation. You
should consult with a specialist where appropriate. Further, readers should be aware that websites listed
in this work may have changed or disappeared between when this work was written and when it is read.
Neither the publisher nor authors shall be liable for any loss of profit or any other commercial damages,
including but not limited to special, incidental, consequential, or other damages.

Library of Congress Cataloging-in-Publication Data

Names: Bolanakis, Dimosthenis E., 1978– author.


Title: Microcontroller prototypes with Arduino and a 3D printer : learn,
program, manufacture / Dimosthenis E. Bolanakis.
Description: Hoboken, NJ : Wiley, 2021. | Includes bibliographical
references and index.
Identifiers: LCCN 2021003270 (print) | LCCN 2021003271 (ebook) | ISBN
9781119782612 (cloth) | ISBN 9781119782674 (adobe pdf) | ISBN
9781119782681 (epub)
Subjects: LCSH: Microcontrollers. | Arduino (Programmable controller) |
Three-dimensional printing.
Classification: LCC TJ223.P76 B665 2021 (print) | LCC TJ223.P76 (ebook) |
DDC 006.2/2–dc23
LC record available at https://lccn.loc.gov/2021003270
LC ebook record available at https://lccn.loc.gov/2021003271

Cover Design: Wiley


Cover Image: © Rasi Bhadramani/iStock/Getty Images

Set in 9.5/12.5pt STIXTwoText by SPi Global, Pondicherry, India

10 9 8 7 6 5 4 3 2 1
I have never seen any of the 7 wonders of the world. I believe there are more though!
To my wife and my three kids
vii

Contents

About the Author xi


List of Figures xii
List of Tables xxvi
Preface xxvii
Acknowledgments xxx
Abbreviations xxxi
Syllabus xxxv

1 The Art of Embedded Computers 1


­Overview of Embedded Computers and Their Interdisciplinarity 1
Computer vs. Embedded Computer Programming and Application
Development 2
Group 1: Programmable Logic Devices 3
Group 2: Reconfigurable Computers 4
Group 3: Microcomputers 4
Group 4: Single-Board Computers 6
Group 5: Mobile Computing Devices 6
­TPACK Analysis Toward Teaching and Learning Microcomputers 7
TPACK Analysis of the Interdisciplinary Microcontroller Technology 7
Content Knowledge (The What) 8
Technology Knowledge (The Why) 9
Pedagogical Knowledge (The How) 11
­From Computational Thinking (CT) to Micro-CT (μCT) 12
CT Requirement and Embedded Computers 13
Microcomputers and Abstraction Process 14
The μCT Concept: An Onion Learning Framework 15
“Transparent” Teaching Methods 17
­The Impact of Microcontroller Technology on the Maker Industry 19
Hardware Advancement in μC Technology 20
Software Advancement in μC Technology 23
The Impact of Arduino on the μC Community 23
­Where Is Creativity in Embedded Computing Devices Hidden? 26
Creativity in Mobile Computing Devices: Travel Light, Innovate Readily! 26
Communication with the Outside World: Sensors, Actuators, and Interfaces 28
­Conclusion 30
viii Contents

2 Embedded Programming with Arduino 31


­Number Representation and Special-Function Codes 31
­Arduino and C Common Language Reference 34
­Working with Data (Variables, Constants, and Arrays) 36
Arduino UART Interface to the Outside World (Printing Data) 39
Arduino Ex.2–1 40
Arduino Ex.2–2 44
­Program Flow of Control (Arithmetic and Bitwise Operations) 47
Arduino UART Interface (Flow of Control and Arithmetic/­
Bitwise Examples) 52
Arduino Ex.2–3 52
Arduino Ex.2–4 53
Arduino Ex.2–5 54
Arduino Ex.2–6 59
Arduino Ex.2–7 63
­Code Decomposition (Functions and Directives) 69
Arduino Ex.2–8 69
­Conclusion 72
Problem 2–1 (Data Output from the μC Device: Datatypes and Bytes
Reserved by the hw) 73
Problem 2–2 (Data Output from the μC Device: Logical Operators
in Control Flow) 73
Problem 2–3 (Data Input to the μC Device: Arithmetic and Bitwise
Operations) 73
Problem 2–4 (Code Decomposition) 73

3 Hardware Interface with the Outside World 75


­Digital Pin Interface 75
Arduino Ex.3.1 76
Arduino Ex.3.2 77
Arduino Ex.3.3 81
Arduino Ex.3.4 82
Arduino Ex.3.5 84
­Analog Pin Interface 86
Arduino Ex.3.6 87
Arduino Ex.3.7 91
­Interrupt Pin Interface 91
Arduino Ex.3.8 94
­UART Serial Interface 96
Arduino Ex.3.9 97
Arduino Ex.3.10 98
Arduino Ex.3.11 99
­SPI Serial Interface 101
Arduino Ex.3.12 103
Contents ix

Arduino Ex.3.13 110


Arduino Ex.3.14 115
Arduino Ex.3.15 121
­I2C Serial Interface 122
Arduino Ex.3.16 125
Arduino Ex.3.17 130
Arduino Ex.3.18 135
Arduino Ex.3.19 142
­Conclusion 146
Problem 3.1 (Data Input and Output to/from the μC Using
Push-Button and LED IO Units) 147
Problem 3.2 (PWM) 147
Problem 3.3 (UART, SPI, I2C) 147

4 Sensors and Data Acquisition 149


­Environmental Measurements with Arduino Uno 149
Arduino Ex.4–1 150
DAQ Accompanying Software of the Ex.4–1 157
DAQ Accompanying Software with Graphical Monitoring ­
Feature Via gnuplot 166
Arduino Ex.4–2 169
­Orientation, Motion, and Gesture Detection with Teensy 3.2 171
Arduino Ex.4–3 173
Arduino Ex.4–4 174
Arduino Ex.4–5 177
Arduino Ex.4–6 184
DAQ Accompanying Software for Orientation, Motion,
and Gesture Detection with gnuplot 191
Real Time Monitoring with Open GL 193
­Distance Detection and 1D Gesture Recognition with TinyZero 200
Arduino Ex.4–7 201
Arduino Ex.4–8 205
DAQ Accompanying Software for Distance Measurements 209
­Color Sensing and Wireless Monitoring with Micro:bit 211
Arduino Ex.4–9 212
Arduino Ex.4–10 216
Open GL Example Applying to RGB Sensing 220
Arduino Ex.4–11 222
­Conclusion 226
Problem 4–1 (Data Acquisition of Atmospheric Pressure) 226
Problem 4–2 (Fusion of Linear Acceleration and ­
Barometric Altitude) 226
Problem 4–3 (1D Gesture Recognition) 226
Problem 4–4 (Color Sensing) 226
x Contents

5 Tinkering and Prototyping with 3D Printing Technology 227


­Tinkering with a Low-cost RC Car 227
Arduino Ex.5.1 231
Arduino Ex.5.2 236
­A Prototype Interactive Game for Sensory Play 237
Hardware Boards of the Prototype System 238
Assembly Process of the 3D Printed Parts of the System’s Enclosure 243
Firmware Code Design and User Instructions 249
Arduino Ex.5.3 250
Arduino Ex.5.4 253
Arduino Ex.5.5 256
Arduino Ex.5.6 260
­3D Printing 262
Modeling 3D Objects with FreeCAD Software 262
Preparing the 3D Prints with Ultimaker Cura Software 269
3D Printing with Prima Creator P120 272
Presentation of the Rest 3D Models of the Prototype Interactive Game 276
PrototypeB (Modeling the battery.stl Part) 276
PrototypeC (Modeling the booster.stl Part) 278
PrototypeD (Modeling the speaker.stl Part) 283
PrototypeE (Modeling the cover.stl Part) 284
PrototypeF (Modeling the button.stl Part) 287
PrototypeG (Modeling the sensor.stl Part) 290
PrototypeH (Modeling the front.stl Part) 290
­Conclusion 294
Problem 5.1 (Tinkering with a Low-cost RC Car) 294
Problem 5.2 (A Prototype Interactive Game for Sensory Play) 294
Problem 5.3 (A Prototype Interactive Game for Sensory Play) 295
Problem 5.4 (A Prototype Interactive Game for Sensory Play) 296
Problem 5.5 (3D Printing) 296

References 297
Index 301
xi

About the Author

Dimosthenis (Dimos) E. Bolanakis was born in


Crete, Greece (1978) and graduated in Electronic
Engineering (2001) from ATEI Thessalonikis,
Greece. He received the MSc degree (2004) in
Modern Electronic Technologies and the PhD
degree (2016) in Education Sciences (focusing on
Remote Experimentation), both from University
of Ioannina, Greece. He has (co)authored more
than 30 papers (mainly on Research in Engineering
Education) and 3 books. He has held positions in
both industry and education and his research
interests focus on μC-based and FPGA-based
Hardware Design and Research in Education. He
currently lives in Athens (Greece) together with
his wonderful wife Katerina and their three
delightful kids, Manolis, Eugenia, and Myronas.­
xii

List of Figures

1.1 Interdisciplinarity of embedded computers. 2


1.2 Problem-solving with microcomputers (a revision of Kordaki’s model). 10
1.3 (a) TPACK model and (b) its application in microcontroller education. 12
1.4 Onion learning framework for μC programming and application development. 16
1.5 An example of pseudo-architecture, pseudo-timing diagram, and
pseudo-hardware. 18
1.6 (a) μC programming board and (b) UVPROM eraser (from the long-cycle era). 21
1.7 Custom-designed PCB of the μC’s application circuit. 21
1.8 (a) Arduino uno board and powerpack shield; (b) Arduino Uno and Ethernet
shield. 22
1.9 Uploading the new firmware code to μC’s memory through the Arduino IDE. 24
1.10 PCB silkscreen of the Arduino Uno stackable headers and the μC’s digital IO
pins. 26
1.11 A drone is built around sensors, actuators, and interfaces. 29
2.1 Example of a 16-bit register in μC’s memory. 32
2.2 Two’s (2’s) complement geometrical representation of a 4-bit binary number. 33
2.3 Arduino Uno board connected to the USB port of a laptop (using type A to B
cable). 40
2.4 Arduino Ex.2–1a: output data from the μC to a computer through UART. 41
2.5 RS 232 terminal consoles: (a) Arduino serial monitor. (b) Termite. 42
2.6 Arduino Ex.2–1b: (a) SRAM-memory and (b) Flash-memory strings. 45
2.7 Arduino Ex.2–2: datatypes length and typecasting. (a) source code, (b) printed
results. 46
2.8 Control flow statements in Arduino (and embedded C) programming. (a) general
syntax of the goto statement, (b) example of the goto statement, (c) general syntax
of the if statement, (d) example of the if statement, (e) general syntax of the if/else
statement, (f) example of the if/else statement, (g) general syntax of the if/else if
statement, (h) example of the if/else if statement, (i) general syntax of the
switch. . .case statement, (j) example of the switch. . .case statement, (k) general
syntax of the for statement, (l) example of the for statement, (m) example of the for
loop along with the continue statement, (n) general syntax of the while statement,
(o) example of the while statement, (p) general syntax of the do. . .while statement,
(q) example of the do. . .while statement. 49
List of Figures xiii

2.9 Flowchart of the for() loop example given in Figure 2.14m. 51


2.10 Flowchart of the do. . .while() loop example given in Figure 2.8q. 52
2.11 (a) Arduino Ex.2–3: for() & while() statements and variable scope. (a) for loop
example code, (b) for loop printed results, (c) while loop example code, (d) while
loop printed results. 53
2.12 Arduino Ex.2–4: for() statement and Boolean operators (upper/lower case letters).
(a) logical OR example code, (b) logical OR printed results, (c) logical AND example
code, (d) logical AND printed results. 54
2.13 Arduino Ex.2–5: input data to the μC from a computer through UART (pointers).
(a) flowchart, (b) source code. 55
2.14 Printed results of the original version (and some revisions) of Arduino Ex.2–5. (a)
Termite terminal console for transmitting characters to the μC from a PC, (b)
Transmission of a string to the μC device (error during the foremost transmis-
sion), (c) Retransmission of the string (errorless results after the foremost
transmission), (d) String transmission with pointers using unary increment
operator (syntax 1), (e) String transmission with pointers using unary increment
operator (syntax 2), (f) String transmission with pointers using unary increment
operator (syntax 3). 58
2.15 Arduino Ex.2–6a: arithmetic operations (numeric string to binary value). (a)
flowchart, (b) source code, (c) printed results. 60
2.16 Transforming a numeric string to binary value (“128”→128). (a) the ASCII
numbers ‘1’–‘9’, (b) storage of the ASCII numbers ‘1’, ‘2’, and ‘8’ to three
memory locations, (c) process of converting a string to binary number through
a loop. 61
2.17 Arduino Ex.2–6b: arithmetic operations (binary value to numeric string). (a) source
code (part 1 of 2), (b) source code (part 2 of 2), (c) printed results. 62
2.18 Transforming a binary value to BCD in reversed order (254→“452”). 63
2.19 Arduino Ex.2–7: bitwise operations (unsigned byte to signed byte conversion).
(a) source code (part 1 of 2) (b) source code (part 2 of 2) (c) printed results (d)
geometrical representation of unsigned and 2’s complement signed numbers
(byte-size long). 64
2.20 Bitwise AND, OR, XOR with bitmasks. (a) bitwise AND (b) bitwise OR (c) bitwise
XOR (toward inverting bits) (c) bitwise XOR (toward evaluating the equality of
variables). 65
2.21 Converting the array elements from BCD to ASCII and printing them in regular
order. (a) storage of the byte-size numbers 1, 2, 8 in memory, in reverse order,
(b) execution of the while loop for converting numbers to ASCII characters and
execution of the do. . .while loop for rearranging the order of characters in
memory. 67
2.22 Bit-shift left (<<) and right (>>) of a binary value (multiply and divide by 2×). (a)
source code, (b) printed results. 68
2.23 Three positions bit-shift left and right (i.e. multiply and divided by 23). (a) general
description of bit-shift left execution, (b) general description of bit-shift right
execution, (c) example of bit-shift left execution, (d) example of bit-shift right
execution. 68
xiv List of Figures

2.24 Function declaration in Arduino (and Embedded C) programming.


(a) general syntax of a function declaration in C language statement,
(b) example of a function declaration of neither arguments nor returning
value, (c) example of a function declaration admitting arguments as well as
returning value. 70
2.25 Arduino Ex.2–8: code decomposition with functions (as applied to Arduino
Ex.2–7). (a) header file, (b) source code invoking the header file. 71
2.26 Arduino Ex.2–8b: code decomposition with functions and macros. (a) source code
invoking macros, (b) printed results, (c) general syntax of a function-like macro,
(d) example of a function-like macro, (e) general syntax of an object-like macro,
(f) example of an object-like macro. 72
3.1 Pin interface with the outside world: OUTPUT DATA. (a) LED on Arduino Uno
board, (b) flowchart of the example code, (c) example firmware code, (d) updated
firmware using global variables, (e) updated firmware using object-like
macros. 76
3.2 Blinking LED with user-defined function and macro. (a) firmware code imple-
mented with functions, (b) firmware code implemented with function-like
macros. 77
3.3 Pin arrangement in an Arduino Uno board (port B, port C, and port D). 78
3.4 Blinking LED through the direct manipulation of the port registers. (a) firmware
example code with direct port manipulation, (b) updated code with bitwise
operations, (c) updated code with function-like macros, (d) printed results on
Arduino serial monitor tool, (e) the execution of bitwise AND/OR operations for
turning the LED ON/OFF. 79
3.5 Waveforms on PB5 pin (blinking LED without the one second delay).
(a) connection of the oscilloscope to pin PB5 of the Arduino Uno to acquire the
blinking period, (b) pulse of the PB5 when applying direct manipulation of the port
pins (375ns), (c) pulse of the PB5 when applying bitwise operations to the port pins
(500ns), (d) pulse of the PB5 when using user-defined macros to control the port
pins (750ns). 81
3.6 Concurrent vs. sequential manipulation of the μC’s port pins. (a) example firmware,
(b) connection of the oscilloscope to pins PB4 and PB5 of the Arduino Uno, (c)
delay when manipulating the port pins concurrently (ns), (d) delay when manipu-
lating the port pins sequentially (μs). 82
3.7 Pin interface with the outside world: INPUT DATA. (a) release push-button
to turn the LED ON, (b) press the push-button to turn the LED OFF,
(c) connection diagram of the push-button to PIN12, (d) example firmware
and flowchart. 83
3.8 Debounce the spurious switch (open/close) transitions. (a) connection diagram of a
push-button with pull-up resistor, (b) expected and actual signal waveform when
pressing the push-button, (c) flowchart of the application example, (d) firmware of
the application example. 85
3.9 Reading the switch state through the direct manipulation of PINB register. (a)
example firmware, (b) bitwise operations on the register of PORTB. 86
List of Figures xv

3.10 Analog signal and PWM arrangement in an Arduino Uno board. (a) example of an
analog signal, (b) PWM example of 50%DC, (c) PWM example of 25%DC, (d) PWM
example of 75%DC. 87
3.11 ADC and PWM pin arrangement in an Arduino Uno board. 88
3.12 Reading the switch state through the analog input pin A0. (a) hardware setup,
(b) example firmware, (c) printed results (ADC value in decimal representation),
(d) printed results (ADC value in volts), (e) plot of the ADC value in volts with the
Arduino serial plotter. 89
3.13 Reading the 3V3 power on an Arduino Uno board through the analog A0 pin.
(a) hardware setup, (b) example firmware, (c) plot of acquired signal, (d) printed
results of acquired signal. 90
3.14 PWM on PIN3 on an Arduino Uno board (data acquisition though PINA0). (a)
hardware setup, (b) example firmware, (c) plot of the PWM signal of DC 25% and
75%, (d) plot of the PWM signal of DC 75% and 50%. 92
3.15 PWM on PIN3 (data acquisition though oscilloscope). (a) connection of the
oscilloscope to PIN3 of the Arduino Uno, (b) mean value of PWM signal of 50% DC
(2.61V), (c) mean value of PWM signal of 25% DC (1.34V), (d) mean value of PWM
signal of 75% DC (3.89V). 93
3.16 External interrupt pins on an Arduino Uno board. 93
3.17 Update DC of the PWM wave on PIN3 via the external interrupt on PIN2. (a)
example firmware, (b) printed results. 95
3.18 Switch bounce on the external interrupt PIN2. (a) hardware setup, (b) signal
acquisition of PIN2 with the oscilloscope. 95
3.19 UART connection of a μC to a μC, module, or computer (8N1 frame).
(a) connection diagram, (b) generalized data frame in UART communication,
(c) transmission of the ‘A’ character in UART 8N1 format. 96
3.20 UART hardware interface on an Arduino Uno board (pinout and data framing).
(a) UART pin arrangement on the hardware board, (b) example firmware, (c) signal
acquisition of UART TX line with the oscilloscope, (d) printed results, (e) data
frame of the transmitted ‘A’ character acquired by the oscilloscope. 97
3.21 Third-party tools for the Arduino Uno board (FTDI click by
MikroElektronika). 98
3.22 UART hardware interface on an Arduino Uno using third-party tools (by
MikroElektronika). (a) example firmware, (b) hardware setup, (c) COM ports
reserved by the FTDI chip, (d) printed results in Termite console. 99
3.23 Software-implemented UART on an Arduino Uno board (SoftwareSerial library).
(a) example firmware, (b) hardware setup: open circuit between the software-based
and the hardware-based UART, (c) apply short circuit between software-based TX
line and hardware-based RX line, (d) printed results in Termite console. 100
3.24 SPI hardware topology and read/write timing diagrams (four modes of
­operation). (a) connection diagram between the μC and a single SPI device, (b)
connection diagram between the μC and two SPI devices, (c) single-byte read
timing d­ iagrams of the SPI protocol, (d) single-byte write timing diagrams of the
SPI protocol. 102
xvi List of Figures

3.25 SPI single-byte read of the chip id of BME280 sensor device. (a) example firmware,
(b) hardware setup: SPI configuration of the Weather Click module, (c) printed
results in Termite console. 105
3.26 SPI single-byte read of the chip id of BME280 sensor device (timing diagrams).
(a) SPI pin arrangement on the Arduino Uno board, (b) capture the SPI pins with
an oscilloscope via the header of the Arduino Uno click shield, (c) acquisition of the
SPI single-byte read timing diagrams with the oscilloscope. 106
3.27 SPI single-byte write and read (BME280 register 0×F4, aka “ctrl_meas”).
(a) example firmware, (b) acquisition of the SPI single-byte write/read timing
diagrams with the oscilloscope. 107
3.28 SPI multiple-byte read (BME280 temperature coefficients 0×88–0×8D). (a) example
firmware, (b) printed results, (c) acquisition of the SPI multiple-byte read timing
diagrams with the oscilloscope (1 of 2), (d) acquisition of the SPI multiple-byte
read timing diagrams with the oscilloscope (2 of 2). 109
3.29 BME280: obtain temperature (T), humidity (H), and pressure (P) through the built-in
SPI. (a) application firmware, (b) application flowchart, (c) printed results. 111
3.30 BME280 SPI functions (1 of 3). 113
3.31 BME280 SPI functions (2 of 3). 114
3.32 BME280 SPI functions (3 of 3). 115
3.33 Header file of the custom-designed SPI library (swSPI.h). 116
3.34 Source code file of the custom-designed SPI library (swSPI.cpp – 1 of 2). 117
3.35 Source code file of the custom-designed SPI library (swSPI.cpp – 2 of 2). 118
3.36 swSPI single-byte read of the chip id of BME280 sensor device. (a) example
firmware: software-implemented SPI, (b) capture the SPI pins with an oscilloscope
(the software-implemented SPI pins are intentionally assigned to the location
where the built-in SPI pins are originally traced), (c) printed results in Termite
console, (d) acquisition of the software-based SPI single-byte read timing diagrams
with the oscilloscope. 120
3.37 SCLK period of the swSPI library. (a) SPI clock period using 100us delay, (b) SPI
clock period using nop assembly mnemonic (minimum delay). 121
3.38 BME280: obtain temperature, humidity, and pressure through the swSPI library.
(a) application firmware, (b) printed results. 122
3.39 I2C hardware topology and read/write timing diagrams. (a) connection diagram
between the μC and a single I2C device, (b) connection diagram between the μC
and multiple I2C devices, (c) timing diagrams of a successful I2C write transaction
to a single slave register, (d) timing diagrams of a successful I2C read transaction to
a single slave register. 124
3.40 I2C hardware interface (Arduino Uno and BME280/click shield pinout). (a) I2C
pin arrangement on the Arduino Uno board, (b) hardware setup: I2C configuration
of the Weather Click module. 125
3.41 I2C single-byte read of the chip id of BME280 sensor (code and timing diagrams).
(a) the previous single-byte SPI read firmware to highlight code differences with
the I2C, (b) single-byte I2C read example firmware, (c) printed results, (d)
acquisition of the I2C single-byte read timing diagrams with the
oscilloscope. 127
List of Figures xvii

3.42 I2C single-byte write and read code (BME280 register 0×F4, aka “ctrl_meas”).
(a) the previous single-byte SPI write/read firmware to highlight code differences
with the I2C, (b) single-byte I2C write/read example firmware, (c) printed
results. 128
3.43 I2C single-byte write and read timing diagrams (BME280 “ctrl_meas” register).
(a) acquisition of the I2C single-byte write timing diagrams with the oscilloscope,
(b) acquisition of the I2C single-byte read timing diagrams with the
oscilloscope. 129
3.44 I2C multiple-byte read (BME280 temperature coefficients 0×88–0×8D). (a) the
previous multiple-byte SPI read firmware to highlight code differences with the
I2C, (b) multiple-byte I2C read example firmware, (c) printed results,
(d) acquisition of the I2C multiple-byte read timing diagrams with the
oscilloscope. 130
3.45 BME280: obtain Temperature (T), Humidity (H), and Pressure(P) through the
built-in I2C. (a) the previous application firmware of SPI configuration to highlight
code differences with the I2C, (b) application firmware of I2C configuration,
(c) printed results. 131
3.46 BME280 I2C functions (1 of 3). 132
3.47 BME280 I2C functions (2 of 3). 133
3.48 BME280 I2C functions (3 of 3). 134
3.49 Header file of the custom-designed I2C library (swWire.h). 136
3.50 Source code file of the custom-designed I2C library (swWire.cpp – 1 of 4). 137
3.51 Source code file of the custom-designed I2C library (swWire.cpp – 2 of 4). 137
3.52 Source code file of the custom-designed I2C library (swWire.cpp – 3 of 4). 139
3.53 Source code file of the custom-designed I2C library (swWire.cpp – 4 of 4). 140
3.54 swWire single-byte read of the chip id of BME280 sensor device. (a) example
firmware: software-implemented I2C, (b) the previous example firmware of built-in
I2 configuration to highlight code differences with the software-implemented I2C,
(c) printed results, (d) acquisition of the software-based I2C single-byte read timing
diagrams with the oscilloscope. 141
3.55 SCL max frequency of the swWire library on an Arduino Uno board. 142
3.56 BME280: obtain temperature, humidity, and pressure through the swI2C library. (a)
application firmware of the software-implemented I2C, (b) the previous application
firmware of built-in I2 configuration to highlight code differences with the soft-
ware-implemented I2C, (c) printed results. 143
3.57 BME280 revised driver (1 of 3). 144
3.58 BME280 revised driver (2 of 3). 145
3.59 BME280 revised driver (3 of 3). 146
4.1 Amendments to the BME280 driver of the built-in I2C interface. (a) revision of
BME280 driver of the built-in I2C interface, (b) first version of BME280 driver
(presented by the previous chapter). 152
4.2 DAQ measurement hardware and firmware (air pressure with BME280 sensor).
(a) application code, (b) printed results, (c) DAQ hardware, (d) a revision of the
application code. 153
xviii List of Figures

4.3 Pulse on PINA3 (DAQpin) for measuring the time of DAQ process. (a) pulse on
PINA3 code: 100 samples acquisition @1.42s, (b) pulse on PINA3 code: single
sample acquisition @14.2ms, (c) pulse on PINA3 code: single sample
acquisition @1.4ms, (d) pulse on PINA3 code: 100 samples acquisition
@1.34s. 156
4.4 Header file Serial.h for the communication with the PC serial port (1 of 2). 157
4.5 Header file Serial.h for the communication with the PC serial port (2 of 2). 159
4.6 DAQ software for the communication with the PC serial port
(Serial_Ex4_01.c). 161
4.7 Arduino Uno connected to COM11 serial port (Windows
Device Manager). 163
4.8 Compilation and execution of the DAQ software. 163
4.9 Enrichment of the DAQ software Serial_Ex4_01.c to store data to a text file.
(a) code instructions to create a new file and write data to it, (b) code instructions
to keep the existing file and append new data to it, (c) data written to the file
measurements.txt. 164
4.10 Free Serial Port Monitor tool for inspecting the data exchanged by the COM port.
(a) create new session: select serial device, (b) create new session: select data view
mode, (c) data captured by the software. 165
4.11 DAQ software with graphical monitoring feature (Serial_Ex4_01-gnuplot.c).
(a) application software code, (b) application firmware code. 167
4.12 Compilation and execution of the Serial_Ex4_01-gnuplot.c DAQ software.
(a) Windows command prompt console, (b) data stored to Pressure.dat, (c) plot of
measurements with gnuplot (example 1), (d) plot of measurements with gnuplot
(example 2). 169
4.13 DAQ measurement hardware and firmware (reading data from two sensors).
(a) DAQ firmware, (b) DAQ hardware, (c) plot of measurements with serial
plotter. 170
4.14 DAQ with data monitoring acquired by 2 sensors (Serial_Ex4_02-gnuplot.c).
(a) application software code, (b) data output with Windows command prompt
console, (c) plot of measurements with gnuplot. 172
4.15 Teensy 3.2 USB development board (Top and Bottom view). 174
4.16 Getting started with Teensy 3.2 board (example firmware). (a) firmware code,
(b) configuring Teensy board in Arduino IDE, (c) download code to Teensy board
(step 1), (d) download code to Teensy board (step 2), (e) download code to Teensy
board (step 3), (f) printed results. 175
4.17 BNO055+BMP280 Pesky module for Teensy 3.2 motherboard. (a) the Pesky module
(left side) and the Teensy board (right side), (b) pin header for attaching together
the two modules, (c) pin header soldered to the Teensy board, (d) the Pesky module
soldered on the top of Teensy board. 176
4.18 Reading air pressure from BMP280 sensor of Pesky’s module
(with Teensy 3.2). (a) application firmware code, (b) application software
code (header file), (c) application software code (source code), (d) data
output with Windows command prompt console, (e) plot of measurements
with gnuplot. 178
List of Figures xix

4.19 3D orientation of BNO055 device using Euler angles. (a) reference x,y,z axes of
BNO055 device, (b) reference position of BNO055 device on the top of Teensy
board, (c) rotation of the hardware setup around x axis: pitch angle, (d) rotation of
the hardware setup around y axis: roll angle, (e) rotation of the hardware setup
around z axis: yaw angle. 179
4.20 Gimbal lock phenomenon in Euler angles. (a) independent gimbals. 180
4.21 BNO055 driver (using the built-in I2C). 182
4.22 Orientation detection expressed with Euler angles. (a) application firmware,
(b) hardware setup, (c) plot of measurements with serial plotter. 183
4.23 Gesture and motion detection firmware. 185
4.24 Gesture detecting sleeve and gesture types. (a) the various types of gesture of the
current application, (b) gravity applied to the mass of a single-axis accelerometer,
(c) hardware setup and gesture demonstration examples, (d) gravity applied to the
mass of a three-axis accelerometer. 186
4.25 Gesture detection via Gravity Vector (gestures aligned with the direction of
gravity). 188
4.26 Gesture recognition graphs. 189
4.27 Gesture recognition example toward steering an RC car. (a) plot of gravity
measurements of a particular gesture (example 1), (b) plot of gravity measurements
of a particular gesture (example 2), (c) plot of gravity measurements of a particular
gesture (example 3). 190
4.28 Motion detection via Linear Acceleration. (a) reference position of BNO055
device on the top of Teensy board, (b) accelerating BNO055 sensor along x axis,
(c) accelerating BNO055 sensor along y axis, (d) accelerating BNO055 sensor
along z axis. 191
4.29 Motion detection (Linear Acceleration) graphs and revised firmware. (a) application
firmware: revisions for reading gravity and linear acceleration, (b) plot of BNO055
displacement on x,y,z axis, (c) plot of BNO055 displacement along x axis, (d) plot of
BNO055 displacement along y axis, (e) plot of BNO055 displacement along z
axis. 192
4.30 Fusing Linear Acceleration and Barometric Altitude toward absolute height
calculation. 193
4.31 Updated firmware and DAQ running for Euler angles, Gravity, Linear Acceleration.
(a) revised firmware code to work with a custom-designed software (Euler angles),
(b) updates of the latest firmware code for obtaining gravity and linear acceleration,
(c) compilation and execution of the custom-designed software, (d) plot of Euler
angles obtained from the custom-designed software, (e) plot of gravity vector
obtained from the custom-designed software, (f) plot of linear acceleration obtained
from the custom-designed software. 194
4.32 DAQ software for acquiring Euler angles, Gravity, and Linear Acceleration. 195
4.33 Compilation and execution of the Open GL example code. (a) real-time response of
a 3D box (printed on the PC screen) according to the Euler angles obtained from
BNO055 sensor (demonstration example 1), (b) real-time response of the 3D box
(demonstration example 2), (c) real-time response of the 3D box (demonstration
example 3). 197
xx List of Figures

4.34 Open GL example applying to Euler angles (1 of 2). 198


4.35 Open GL example applying to Euler angles (2 of 2). 199
4.36 TinyCircuits vs. Teensy board systems. 201
4.37 Battery operated system with TinyZero and Teensy (with Adafruit Feather).
(a) TinyZero board, (b) Teensy 3.X Feather Adapter along Teensy3.2 board. 202
4.38 TinyCircuits SAMD Boards by TinyCircuits installed. 203
4.39 Teensy USB Serial driver installed for TinyZero board. (a) driver installation
process (step 1), (b) driver installation process (step 2), (c) driver installation
process (step 3), (d) configuring TinyZero board in Arduino IDE. 204
4.40 Force TinyZero board into bootloader code (if not automatically inserted). 205
4.41 Getting started with “Hello World!” and blinking LED firmware (TinyZero board).
(a) example firmware for TinyZero, (b) LED on TinyZero board, (c) updated
firmware to maintain code compatibility with different hardware platforms, (d)
printed results of the example firmware. 206
4.42 Distance measurements and gesture recognition setup & firmware. (a) application
hardware, (b) application firmware. 207
4.43 Distance measurements with one VL53L0X: (a) serial monitor, (b) serial plotter. 208
4.44 1D gesture recognition by reading two identical VL53L0X sensors. (a) firmware
revision to read data from two identical sensors, (b) user interaction with the
hardware: Gesture 1, (c) user interaction with the hardware: Gesture 2, (d) plots
obtained from the two different gestures, (e) measurements obtained from the two
different gestures. 209
4.45 1D gesture recognition by reading two identical VL53L0X sensors. 210
4.46 DAQ software applying to distance detection (illustrating VL53L0X
accuracy). 211
4.47 mbed driver successfully installed. (a) top view of Micro:bit board, (b) bottom view
of Micro:bit board, (c) driver installation for the Micro:bit board. 213
4.48 Installing Nordic Semiconductor nRF5 Boards by Sandeep Mistry. 213
4.49 Configure the Arduino IDE in order to upload code to Micro:bit. 214
4.50 Approve the code uploading process to Micro:bit. 214
4.51 Hardware of blinking LED (using push-buttons) in Micro:bit. (a) push-buttons and
LEDs on Micro:bit board, (b) connection diagram of LED1 to the Micro:bit pins,
(c) connection diagram of the two push-buttons to the Micro:bit pins. 215
4.52 Firmware of blinking LED (using push-buttons) in Micro:bit. (a) example
firmware, (b) printed results. 216
4.53 Color codes of Ozobot. 217
4.54 Color sensing setup and testing. (a) edge connector breakout board for Micro:bit by
Kitronik, (b) signals on the Micro:bit edge connector, (c) RGB sensor module by
Adafruit Industries, (d) hardware setup of the current application example, (e) red,
green and blue cards for testing the application, (f) demonstration example:
scanning the red card, (g) demonstration example: scanning the blue card,
(h) demonstration example: scanning the green card. 218
4.55 Firmware and color sensing results. (a) application firmware, (b) plots of
measurements when scanning red, green and blue cards, (c) measurements when
no card is placed above the sensor. 219
List of Figures xxi

4.56 RGB sensing example with Open GL (1 of 2). 220


4.57 RGB sensing example with Open GL (2 of 2). 221
4.58 Execution of the RGB sensing example with Open GL. (a) compilation and
execution of the application software (no colour detected), (b) red colour is
identified by the application software, (c) green colour is identified by the
application software, (d) Blue colour is identified by the application software. 222
4.59 RGB sensing firmware with BLE connectivity. 223
4.60 Interfacing with a mobile phone through BLE (Bluefruit Connect app). (a) the
initial screen on the smartphone when starting the Bluefruit Connect app, (b) the
subsequent screen where the UART module is selected, (c) RGB measurement
obtained from the Micro:bit board, (d) measurements on the smartphone when
scanning red card, (e) measurements on the smartphone when scanning green
card, (f) measurements on the smartphone when scanning blue card, (g)
measurements on Arduino serial monitor when scanning red card, (h)
measurements on Arduino serial monitor when scanning green card, (i)
measurements on Arduino serial monitor when scanning blue card. 224
4.61 RGB sensing firmware with BLE connectivity (central device read & write). (a)
revised firmware to transmit as well as receive data to/from the smartphone, (b) the
Bluefruit Connect app exchanges information with the updated firmware. 225
5.1 Tinkering a 360 Cross RC car by Exost. (a) the 360 Cross RC car by Exost, (b)
reverse engineering of the RC car (step 1), (c) reverse engineering of the RC car
(step 2), (d) reverse engineering of the RC car (step 3). 228
5.2 Connection diagram of the tinkered RC. 230
5.3 Connection diagram of the tinkered RC. (a) top and bottom side of the Dual Motor
Driver module by DFRobot, (b) top and bottom side of the nRF52 Bluetooth module
by Pesky Products, (c) teensy 3.2 μC motherboard within the Grove Wrapper case by
Seeed Studio, (d) PH2.0 connectors attached to the DC motor driver and Teensy
3.2 motherboard. 231
5.4 Tinkering a 360 Cross RC car by Exost. 232
5.5 Tinkering an RC car: testing Control Pad commands (Arduino hardware). (a)
application firmware, (b) printed results. 233
5.6 Tinkering an RC car: testing Control Pad commands (Bluefruit app). (a) select UART
module from the Bluefruit Connect app, (b) Select Controller module from the
Bluefruit Connect app, (c) select Control Pad panel from the Bluefruit Connect app,
(d) command description of the controls available at the Control Pad panel. 234
5.7 Tinkering an RC car: decoding Control Pad commands (Arduino hardware).
(a) application firmware, (b) printed results. 235
5.8 Tinkering an RC car: firmware to control the RC car though a smartphone.
(a) application firmware, (b) anticipated reaction the RC car from the commands
decoded by the firmware. 237
5.9 Upgrading the control of the RC car via the additional Bluefruit app commands. 238
5.10 The proposed interactive game for sensory play. (a) LED ring displaying
green colour, (b) ON/OFF switch and sensors, (c) USB connectors for
uploading code and charging the system battery, (d) different colour displayed
by the LED ring (red). 239
xxii List of Figures

5.11 ZIP Halo board with Micro:bit (for the sense of sight). (a) top side,
(b) bottom side. 240
5.12 Peripheral units used by the prototype game (except ZIP Halo + Micro:bit).
(a) 10DOF sensor module by DFRobot, (b) Distance sensor board (OEM product),
(c) powerboost 1000 charger by Adafruit, (d) speaker module by Waveshare, (e) 5V
fan (OEM product), (f) LiPo battery / 1200mAh (OEM product), (g) ON/OFF slide
switch (OEM product). 241
5.13 Interconnection between the peripheral units of the prototype interactive game.
(a) how to connect the available PH2.0 connectors of the system, (b) PH2.0
connectors properly connected. 242
5.14 Assembly of the system’s enclosure (1 of 3). 244
5.15 Assembly of the system’s enclosure (2 of 3). 245
5.16 Assembly of the system’s enclosure (3 of 3). 246
5.17 Screws, nuts, and spacers required for the system’s assembly. 247
5.18 Bottom-up design method: decomposing the application firmware into three
segments. (a) the LED ring applying to the sight sense, (b) the virtual button applying
to the proprioception sense, (c) the speaker applying to the hearing sense. 250
5.19 Connection diagram of the prototype system. 251
5.20 Generate random (green and red) colors to the LED ring. 252
5.21 Emulate a push-button via a barometric pressure sensor (firmware). (a) application
firmware, (b) requisite amendments to the header (.h) file of the library, (c)
requisite amendments to the source code (.cpp) file of the library, (d) reset button
location on the system. 254
5.22 Emulate a push-button via a barometric pressure sensor (plots). (a) plot of pressure
measurements: changes in the pressure level, (b) plot of pressure measurements:
identify underpressure by the pressure difference. 255
5.23 Notes and frequencies of the piano keys. 257
5.24 Generating by the microcontroller (and playing for 2 s) A4 music note. (a) connec-
tion diagram of the Micro:bit board to a speaker, (b) square waveform of frequency
proportional to A4 note (440Hz). 257
5.25 Header file declaring the semi-period (in μs) of each music note. 258
5.26 Generate random colors to the LED ring and associate sound to each color.
(a) application firmware (1 of 2), (b) application firmware (2 of 2). 259
5.27 Template firmware of the prototype interactive game. (a) application firmware (1 of
2), (b) application firmware (2 of 2), (c) printed results. 261
5.28 FreeCAD: getting started with primitive shapes and Boolean operations. (a) select
the Part Workbench on the FreeCAD, (b) toolbars of primitive objects for modifying
objects appear on the FreeCAD. 263
5.29 FreeCAD: modeling the floor part of the prototype interactive game (step 1).
(a) bottom view activated (key 5), (b) rear view activated (key 4). 264
5.30 FreeCAD: modeling the floor part of the prototype interactive game (steps 2–7).
(a) Design cylinder (R=3.6mm, H=3mm), (b) Change the X position of cylinder
(X=30mm), (c) Design cylinder (R=1.6mm, H=2mm), (d) Change the Z position
of the latter cylinder (Z=3mm), (e) Top view activated, (f) Repeat the latter
design and change X position of the new cylinder (R=1.6mm, H=2mm,
X=-30mm). 266
List of Figures xxiii

5.31 FreeCAD: modeling the floor part of the prototype interactive game (steps 8–13).
(a) design cylinder RxH=3.6x3 mm and modify its position to X=-30mm, (b) select
the four cylinders meant for the holes of the floor part, (c) fuse the selected parts to
a union, (d) Select the main cylinder of the floor part, (e) select the fusion of the
holes, (f) make a cut of two shapes to create the holes to the main cylinder. 267
5.32 Top/bottom view and rotation of the floor part of the prototype interactive game.
(a) top view, (b) bottom view, (c) rotation of the floor part by pressing together the
highlighted buttons of the mouse. 268
5.33 FreeCAD: rename a 3D part and change its appearance to transparency. (a) select
the previous cut of the selected parts, (b) press right click on the mouse and choose
rename, (c) modify appearance of the floor part to transparency, (d) set
transparency to 80%. 268
5.34 Free online STL viewer. 269
5.35 Cura: define settings for Prima Creator P120 3D printer. 270
5.36 Cura: define settings for setting of the desired 3D printing procedure. 271
5.37 Cura: load the .stl file. (a) Cura software buttons for rotating, scaling, and mirroring
the 3D model, (b) rotate 180o the 3D model. 273
5.38 The Prima Creator P120 3D printer. (a) front view, (b) rear view. 274
5.39 Bed leveling of the Prima Creator P120 3D printer. (a) menu for moving manually the
bed and extruder of the 3D printer, (b) menu for moving the bed left/write, forward/
backward, and the extruder up/down, (c) bed leveling using a paper sheet. 275
5.40 Prepare the printing process in Prima Creator P120. (a) preheat menu, (b) set
nozzle and bed temperature, (c) return to the previous view, (d) print menu, (e)
select the .gcode file to be 3D printed, (f) the 3D printer leaves a bullet of filament
in the lower left corner so as to remove the remains of filament extruded during the
preheat process, (g) the printer starts the printing process of the 3D model, (h)
menu illustrating the overall 3D printing progress. 277
5.41 Fill density of the printed part (i.e. 20%). 278
5.42 FreeCAD: modeling the Battery.stl part of the prototype game (1 of 3). (a) place
cylinder R×H=32×2 mm, (b) place cylinder R×H=27×2 mm, (c) apply a cut to the
homocentric cylinders (Cut_RING), (d) place cylinder R×H=2.9×8.75 mm @
X=30mm, (e) place cylinder R×H=1.7×8.75 mm @X=30mm, (f) repeat the latter
two steps to create the same homocentric cylinders @X=–30mm, (g) generate a cut
on the pair of cylinders on the right side of the ring to generate hole and spacer
(Cut_SPACER1), (h) repeat the cut on the left side of the ring to generate the
second hole and spacer (Cut_SPACER2). 279
5.43 FreeCAD: modeling the Battery.stl part of the prototype game (2 of 3). (a) place two
more cylinders R×H=1.7×8.75 mm @X=30mm and X=–30mm, (b) apply a cut
from the ring to finish the holes for the two screws, (c) the overall design is grouped
together to a fusion named Ring,Holes,Spacers, (d) create a cuboid of
L×W×H=40×55×2 mm @X=–20/Y=–27.5 mm, (e) create a cuboid of
L×W×H=3×3×2 mm @X=17/Y=24.5 mm, (f) repeat the latter creation three
successive times and place the cubes @X2/Y2=–20/24.5 mm, @X3/
Y3=–20/–27.5 mm and @X4/Y4=17/–27.5 mm, (g) cut the four small cubes from
the large cuboid (i.e. cut edges of the cuboid), (h) create a cuboid of
L×W×H=2.5×26×8 mm @X=17.5/Y=–13 mm. 280
xxiv List of Figures

5.44 FreeCAD: modeling the Battery.stl part of the prototype game (3 of 3). (a) duplicate
the latter cuboid @X=-20mm location, (b) create a cuboid of LxWxH=6x3x8 mm
@X=4/Y=-26 mm, (c) duplicate the latter cuboid @X=-10/Y=-30 mm, (d) create a
fusion of the last four cuboids (axonometric view activated), (e) the overall parts of
the design are fused together and export the 3D model, (f) the exported file (battery.
stl) is depicted by an online .stl viewer application. 281
5.45 FreeCAD: modeling the Booster.stl part of the prototype game (1 of 1). (a) the
previous design is duplicated and its four walls are selected, (b) the four wall are
deleted from the current design, (c) place cylinder RxH=1.7x2 mm @X=8.75/
Y=20 mm, (d) duplicate the latter cylinder @X=-8.75, (e) cut the latter two
cylinders from the cuboid (to generate two holes) and export the design, (f) the
exported file (booster.stl) is depicted by an online .stl viewer application. 282
5.46 FreeCAD: modeling the Speaker.stl part of the prototype game (1 of 2). (a) the
previous design is duplicated and its four walls are selected, (b) the four wall are
deleted from the current design and the cuboid is selected, (c) delete the cuboid
and increase the outer cylinder of the ring (H=5mm), (d) increase also the height
of inner cylinder of the ring (H=5mm), (e) decrease the height of the spacer on the
right bottom corner (H=5mm), (f) decrease the height of the spacer on the left top
corner (H=5mm). 283
5.47 FreeCAD: modeling the Speaker.stl part of the prototype game (2 of 2). (a) delete
the union of the sub-designs in order to modify the part models, (b) increase the
radius of the two spacers to R=3.5mm, (c) move each spacer 7.5mm closer to ring
center (X1=7.5/X2=-7.5 mm) and create a cuboid of LxWxH=8x7x8 mm, (d) create
hole to the latter cuboid (consider the process described by the text), (e) duplicate
the Cut_Cuboid and change its angle to 180o, (f) fuse together cuboids, holes and
spacers and change the angle of the union to 45o, (g) apply correction to the X,Y
position of the two bearings and export the 3D model, (h) the exported file (speaker.
stl) is depicted by an online .stl viewer application. 285
5.48 FreeCAD: modeling the cover.stl part of the prototype game (1 of 2). (a) create two
cylinders of R1xH1=40x38 mm and R2xH2=34x38 mm, (b) cut the two cylinders to
generate a ring, (c) copy Fusion_Bearings sub-part from the previous design and
paste it to the current, (d) activate bottom view and increase the in between gap of
bearings (X1=7.5/X2=-7.5 mm), (e) change angle of bearings to zero, (f) create a
cuboid of LxWxH=16x13x16.5 mm @X=-8/Y=-42 mm, (g) duplicate cuboid and
modify as follows: LxWxH=16x13x7.5 mm @X=-8/Y=-42/Z=21.5 mm, (h) fuse
cubes together. 286
5.49 FreeCAD: modeling the cover.stl part of the prototype game (2 of 2). (a) cut the
previous fusion of cubes from the ring and export the 3D model, (b) the exported
file (cover.stl) is depicted by an online .stl viewer application. 287
5.50 FreeCAD: modeling the button.stl part of the prototype game (1 of 2). (a) copy
again the Fusion_Bearings sub-part to the current design, (b) create a sphere solid
of R=30.5 mm, (c) modify Angle1 of the sphere to -45o, (d) modify Angle2 of the
sphere to 75o, (e) create a cylinder of RxH=21.5x15 mm, (f) create a cylinder of
RxH=16.5x15 mm, (g) cut homocentric cylinders, (h) modify further the angles
and radius of the sphere so as to fit perfectly on the top of the ring (R=24.54,
Angle1=29o, Angle1=70o). 288
List of Figures xxv

5.51 FreeCAD: modeling the button.stl part of the prototype game (2 of 2). (a) prepare
the rotation of bearings copied from the previous project (consider the process
described by the text), (b) rotate 180o the left bearing (consider the process
described by the text), (c) repeat the process for the bearing on the right side,
(d) increase the length of cuboid of the right bearing so as it touches the ring
(L=11 mm), (e) repeat the process for the left bearing so that it also touches the
ring, (f) insert 9 cylinders on the top of the sphere of RxH=1.5x13 mm each and
fuse them together, (g) cut cylinders from the sphere (to generate holes) and export
the 3D model, (h) the exported file (cover.stl) is depicted by an online .stl viewer
application. 289
5.52 FreeCAD: modeling the sensor.stl part of the prototype game (1 of 2). (a) create a
cuboid of LxWxH=32x27x1.5 mm, (b) create a cuboid of
LxWxH=16.9x12.35x7.5 mm, (c) create a cuboid of LxWxH=13.9x9.35x7.5 mm, (d)
move inner cuboid @X=Y=1.5 mm, (e) cut the latter two cuboids, (f) move the cut
@Y=7.33 mm, (g) duplicate inner cube, (h) move the duplicated part at
Y=8.83 mm (as depicted by the figure). 291
5.53 FreeCAD: modeling the sensor.stl part of the prototype game (2 of 2). (a) create a
cuboid of LxWxH=7.5x13.5x6 mm, (b) create a cylinder of RxH=1.5x1.5 mm and
place it @X=3.7,Y=3 mm, (c) duplicate and move cylinder @X=3.7,Y=23 mm, (d)
group the two cylinders and correct their position (Y=0.5 mm), (e) group together
the selected parts, (f) cut the selected parts from the main surface cuboid, (g)
activate axonometric view and export the 3d model, (h) the exported file (sensor.stl)
is depicted by an online .stl viewer application. 292
5.54 FreeCAD: modeling the front.stl part of the prototype game (1 of 2). (a) create two
cylinders of R1xH1=41x36 mm and R2xH2=40x36 mm, (b) cut the two cylinders to
generate a ring, (c) create two cylinders of R1xH1=41x2 mm and R2xH2=22x2 mm
and cut them to generate a ring, (d) create two cylinders of RxH=1.7x2 mm and
place them at X=30 mm and X=-30 mm, respectively, then change the group angle
to 45o and cut them from the latter ring, (e) create a cuboid of LxWxH=6x8x2 mm,
(f) create a cylinder of R1xH1=1.5x2 mm @X=1.5 mm, Y=-6 mm, (g) duplicate the
latter cylinder @Y=14 mm, (h) group together the cylinders and cuboid and place
them @X=30 mm, Y=-4 mm. 293
5.55 FreeCAD: modeling the front.stl part of the prototype game (2 of 2). (a) duplicate
the latter group (meant to the hold the ToF sensor) and place it @X=-30 mm, (b)
create a similar group of a cuboid and two cylinders for the ON/OFF switch
(consider the process described by the text), (c) place the group meant for the ON/
OFF switch to the position X=5.3,Y=33 mm, (d) fuse the two ToF sensors and the
ON/OFF switch, (e) cut the latter group from the main part and export the 3D
model, (f) the exported file (front.stl) is depicted by an online .stl viewer
application. 295
5.56 Add wireless charging feature on the prototype interactive game. 296­
xxvi

List of Tables

P.1 Recommended syllabus (description of example codes of each lesson). xxxvi


P.2 Arduino-specific (i.e. non-C) functions used by the book examples. xlvii
P.3 Arduino-original, third-party, and custom-designed libraries. xlix
P.4 Custom-designed software running on the host PC. l
2.1 Prevailing numeral systems in μC programming and Arduino representation. 32
2.2 ASCII printable and control characters. 35
2.3 BCD encoding (nibble and byte representation). 36
2.4 Arduino/C common language reference. 37
2.5 Elementary flowchart symbols. 48
2.6 Unary increment operator applied to pointers. 57
2.7 Bitwise AND (&), OR (|), and XOR (^) of two bits (Truth table). 65
3.1 SPI modes of operation (Truth table). 103
3.2 BME280 registers used by the code examples. 112
4.1 Setting registers “ctrl_meas” (0 × F4) and “config” (0 × F5). 151
4.2 Specs of Teensy 3.2 (32-bit μC) and the Arduino Uno (8-bit μC) development
boards. 173
4.3 BNO055 registers used by the book examples. 181
4.4 Data representation of Euler angles and Linear Acceleration/Gravity Vector
data. 181
4.5 Specs of TinyZero and Teensy 32-bit μC development boards. 202
4.6 Specs of Micro:Bit, TinyZero and Teensy 32-bit μC development boards. 212
5.1 BOM of the tinkered RC car project. 229
5.2 BOM of the prototype interactive game. 243
xxvii

Preface

This book provides a guide to learning microcontrollers (μCs), appropriate for educators,
researchers, and makers. Microcontrollers constitute a popular type of embedded comput-
ers. This technology has been experiencing, in the last decade, the widespread dissemina-
tion of do it yourself (DIY) culture and gradually shifting away from electronic engineering
(EE) discipline (where it was originally meant to be used). The today’s wave of the ready-
to-use and stackable μC board systems and the shareable – over the internet – libraries,
render feasible the rapid development of microcontroller-based applications. Furthermore,
the modern μC programming methods have managed to abstract the low-level tasks, and
consequently, today’s technology can also be utilizable by the computer science (CS) disci-
pline. However, to learn, in in-depth, how to develop microcontroller-based products, one
has to pay particular attention to practices related to the hardware domain as well. The
current effort exploits the modern development tools and programming methods, while
also providing a scholastic examination of the critical, hardware-related practices on
microcontrollers. Through a series of carefully designed example codes and explanatory
figures, the book provides to the reader a unique experience on establishing a clear link
between the software and hardware. The latter constitutes perhaps the most challenging
area of study, which could be considered as the basis for making the passage from “have
knowledge of” to “mastering” the design of microcontroller-based projects and applications.
The book also features a theoretical background appropriate for instructors and educa-
tional researchers, which provides to the reader a unique perspective on the educational
aspects related to the process of microcomputer programming and application development.
Chapter 1 is structured with scientific rigorousness and is primarily addressed for edu-
cators and educational researchers. The chapter first introduces a novel classification of
today’s embedded computer systems, in terms of the tasks linked either to the CS or EE
discipline. This interdisciplinary technology between the two disciplines aims at helping
readers clarify the possibilities, limitations, and learning difficulties of each category. Then
the chapter provides a unique perspective on the educational aspects of microcomputer
programming and application development. The original analysis applies to the technologi-
cal pedagogical content knowledge (TPACK) model, and attempts to clarify why the pro-
gramming language should be considered as the technology integration, toward helping
students create their knowledge about the subject matter. It also justifies why the employed
technology may arrange the tutoring more appropriate for either the CS, or the EE, disci-
pline. Subsequent to that analysis, the chapter explores the additional endeavor required to
xxviii Preface

understand the capabilities of microcomputer technology and addresses the coined micro-
computational thinking (μCT) term in order to describe the thought processes involved in
the solutions, carried out by a microcomputer-based system. The μCT term is not differenti-
ated from the existing and well-known computational thinking (CT) concept, but is rather
addressed to reveal the thought processes related to the application development with
embedded computers. Because of the maker movement in education (and the fact that
microcontrollers constitute a low-cost and easily accessible technology that can be straight-
forwardly incorporated within any makerspace), it would be wise to consider an upcoming
turn to the educational research efforts related to microcomputer programming, at expense
of (or complementary to) the conventional computer programming courses. This attempt
would raise questions such as: “What is the difference between programming a regular
computer and a microcomputer? How could we arrange the content knowledge of a techni-
cal subject matter without too much focus on the specified technology?” This chapter
applies to such issues and provides information that can be used as a reference guide for
further educational research in microcontrollers, and embedded computers in general.
Moreover, in order to understand the today’s impact of microcontroller technology on the
maker industry, the reader follows the advancement of microcontroller programming and
application development and identifies the (i) long-cycle and (ii) short-cycle development
eras (in terms of the requisite time needed to learn, program, and develop a microcon-
troller-based application), as well as the recent trends in sensor devices and how they pave
the way for creativity and new solutions in embedded computing devices.
Chapter 2 is structured with less scientific rigorousness and is addressed for engineers
and makers. The reader explores the Arduino software and hardware tools, which have
become a viral technology for microcontrollers as they provide a quick jump-start and flex-
ibility in the implementation of a microcontroller-based project. The chapter summarizes
the fundamental aspects of sequential programming, in consideration of a relative compat-
ibility between the Arduino and C language programming. The authoring strategies of the
chapter apply to the motto “less is more” and address the minimalist principles in the design
of the software. Additionally to the task of reducing the software development to its neces-
sary elements, the chapter exploits the familiar and simplified board called the Arduino
Uno, so as to reduce the use of hardware when there is a need to explore the results occurred
by the execution of an example code. Makers and engineers may directly start from this
particular chapter, in order to make quick jump-start into the practical part of learning
microcontroller.
Chapter 3 applies to practices related to the hardware interface with the outside world.
The chapter starts from the familiarization and utilization of the ready-to-use Arduino
libraries, and gradually moves to more advanced issues, such as interrupting the regular
execution of the code, building libraries from scratch, and so forth. Hence, the chapter
incorporates information that intends to satisfy the curiosity of makers, but also engineers
and researchers who work with microcontroller devices. The purpose of this chapter is to
provide a thorough examination of the hardware interface topics, which are considered of
vital importance when building projects around microcontrollers. Through a scholastic
examination of the critical, hardware-related practices on microcontrollers (arranged
around carefully designed example codes and explanatory figures) the book provides to the
reader a unique experience in establishing a clear link between the software and hardware.
Preface xxix

This area of study is essential in building the solid background required to make the pas-
sage from “have knowledge of” to “mastering” the design of microcontroller-based projects
and applications.
Chapter 4 applies to sensors (used in microcontroller projects) and to the data acquisi-
tion process. Because modern sensor devices constantly pave the way for creativity and
innovation in embedded solutions, this chapter aims to inspire the interest and curiosity of
the reader, through examples that apply to the detection of orientation, motion, gesture,
distance, and color sensing. The examples are implemented with some of the most popular
and contemporary boards in the worldwide market, that is, Teensy 3.2, TinyZero, and
Micro:bit. The examples are designed in a way so that they direct readers in achieving sim-
plicity in design. The process of interfacing with mobile phone through Bluetooth technol-
ogy is also explored. Once again, the explanatory figures of the chapter are conducted with
particular devotion in order to help readers achieve a deep understanding of the
explored topics.
Chapter 5 applies to the tinkering practices of μC-based electronic products using
Arduino-related hardware and software tools, as well as prototyping techniques using 3D
printing technology. Having dealt with the theoretical and practical topics covered by the
previous chapters (mainly by Chapters 2–4), the reader should be ready to proceed to prac-
tices related to real-world projects, as those covered by this particular chapter. Creativity
and simplicity in design are two of main features that are addressed by the carefully thought
examples of this chapter.
The freeware tools used by the current project are the following:
●● Arduino integrated development environment (IDE) Software tool to develop (and
upload) μC code.
●● Termite RS 232 terminal console (data write/read to/from serial port).
●● Free Serial Port Monitor Software tool to spy data exchanged through the serial port.
●● Notepad++ Editor for the source code development.
●● Minimalist GNU for Windows (MinGW) Open source programming tool.
●● Gnuplot Command-line driven graphing utility (can be invoked by C code).
●● OpenGL and GLUT Open graphics library and toolkit for 2D and 3D vector graphics.
●● FreeCAD General-purpose parametric 3D computer-aided design (CAD) modeler.
●● Ultimaker Cura 3D printing software for preparing prints.
Additionally, the book offers a variety of supplementary resources – including source codes
and examples – hosted on an accompanying website to be maintained by the author: www.
mikroct.com.
xxx

­Acknowledgments

I would like to thank God for blessing me with the passion of creation. I am truly thankful
for my family, and I wish to thank my sweet wife Katerina who has always been there, sup-
porting me in pursuing my dreams. I would like to sincerely thank Wiley for the opportu-
nity to publish this project with one of the world’s leading publishers. I thank from the
bottom of my heart my kind commissioning editor, Sandra Grayson, for her trust and all
the support with this project, as well as the rest of the team that worked to complete this
book. Lastly, I am eternally grateful to my generous Professor Georgios A. Evangelakis for
his immense and contribution during my maiden authoring venture.
xxxi

Abbreviations

Greek-English Alphabet:

μC microcontroller
μCT micro-computational thinking
μP microprocessor
μS microsecond(s)
kΩ kiloohm

English Alphabet:

ACC accumulator
ACCLRM accelerometer
ACK acknowledge
ACK(M) acknowledge (master)
ACK(S) acknowledge (slave)
ADC analog-to-digital converter
API application programming interface
APP application
ASCII American standard code for information interchange
ASIC application-specific integrated circuit
B byte
BAT battery
BCD binary-coded decimal
BIN binary
BIT binary digit
BLE Bluetooth low energy
BOM bill of material
CAD computer-aided design
CAN controller area network
CE computer engineering
CSG constructive solid geometry
xxxii Abbreviations

CK content knowledge
cm centimeter
CNC computer numerical control
Coeffs coefficients
CPHA clock phase
CPLD complex programmable logic device
CPOL clock polarity
CPU central processing unit
CS computer science
CT computational thinking
DAC digital-to-analog converter
DAQ data acquisition
DC duty cycle or direct current
DEC decimal
DIY do it yourself
DOF degrees of freedom
EE electronic engineering
EEPROM electrically erasable programmable read-only memory
EN enable
F frequency
FDM fused deposition modeling
FPGA field-programmable gate array
FW firmware
GCC GNU compiler collection
GND ground
GPIO general-purpose input/output
H height
HDL hardware description language
HEX hexadecimal
HW hardware
Hz hertz
I2C inter-integrated circuit
IC integrated circuit
IDE integrated development environment
IO input/output
ISP in-system programming
ISR interrupt service routine
kB kilobyte
L length
LED light-emitter diode
LiPo lithium polymer
LSB least significant bit
LSD least significant digit
MEMS micro-electro-mechanical systems
MinGW minimalist GNU for Windows
Abbreviations xxxiii

MISO master input slave output


MIT Massachusetts Institute of Technology
MOSI master output slave input
m meter(s)
mm millimeter(s)
ms millisecond(s)
MSB most significant bit
MSD most significant digit
NACK no-acknowledge
NACK(M) no-acknowledge (master)
NACK(S) no-acknowledge (slave)
ns nanosecond(s)
ODR output data rate
OEM original equipment manufacturer
OpenGL open graphics library
OS operating system
Pa Pascal
PBL project-based learning
PC program counter or personal computer
PCB printed-circuit board
PCK pedagogical content knowledge
PEI polyetherimide
PETG polyethylene terephthalate glycol
PLA polylactic acid
PLD programmable logic device
PK pedagogical knowledge
PRNG pseudo-random number generator
PTFE polytetrafluoroethylene
PWM pulse width modulation
quo quotient
R radius
RAM random-access memory
RC remote control
reg register
rem remainder
RF radio frequency
RGB red, green, blue
ROM read-only memory
RS-232 recommended standard 232
RTC real-time clock
R/W read/write
s second(s)
SCL serial clock
SCLK serial clock
SDA serial data
xxxiv Abbreviations

SDK software development kit


SiP system in package
SMT surface-mount technology
SoC system on chip
SPI serial peripheral interface
SPLD simple programmable logic device
SS slave select
SRAM static random-access memory
SW software
T time period (or period)
TCK technological content knowledge
ToF time-of-flight
TK technology knowledge
TPACK technological pedagogical content knowledge
TPK technological pedagogical knowledge
UART universal asynchronous receiver/transmitter
USB universal serial bus
UVPROM ultraviolet programmable read-only memory
v volts
VPL visual programming language
W width
xxxv

­Syllabus

The book provides a series of example codes to help learners explore, in practice, the criti-
cal topics related to microcomputer programming as well as to establish a clear link
between the firmware and hardware. The carefully designed examples intend to inspire
readers’ critical thinking and creativity, and help them to gradually make the journey from
“have knowledge of” to “mastering” the design of microcontroller-based projects. Hereafter
is the recommended syllabus. To provide a sense of compatibility between the Arduino and
Embedded C programming, only a limited set of Arduino-specific functions is utilized,
apart from the requisite – in Arduino sketches – setup() and loop() functions.
The first column of Table P.1, presented below, incorporates each lesson of the course.
The second column incorporates the examples codes examined by each lesson. The third
column employs the hardware board where each example runs. The fourth column pro-
vides information about the accompanying software needed to explore each particular
example. The final column provides information about what readers can expect to learn by
each example code. In addition, Table P.2 summarizes the Arduino-specific (i.e. non-C
language) functions used by the book. Then Table P.3 presents the Arduino-original, third-
party, as well as the custom-designed libraries. Finally, Table P.4 introduces the custom-
designed software running on the host personal computer (PC).
xxxvi ­Syllabu

Table P.1 Recommended syllabus (description of example codes of each lesson).

Lesson Example Hardware Software Description

1 Ex2_1 Arduino Uno Arduino serial Data output from the μC to a host
monitor and PC. The reader explores: (i) printable
temite and nonprintable ASCII characters and
strings; (ii) storage of stings in either
Data Memory or Program Memory of
Arduino Uno.
Ex2_2 Arduino Uno Arduino serial Datatypes and typecasting tasks. The
monitor reader explores: (i) signed/unsigned
data, datatypes of bool, char, short, int,
long, and float; (ii) typecasting
conversions between datatypes; (iii)
number of bytes reserved in Arduino
Uno memory by each particular
datatype (sizeof() operator).
2 Ex2_3 Arduino Uno Arduino serial Program flow of control. The reader
monitor explores: (i) unconditional branching
with while(); (ii) repetition of a code
part with for(); (iii) the variable scope
coding style in for() loops. Examples are
applied to printable and nonprintable
ASCII and to typecasting, while the
assignment (=), comparison (<), and
compound (++) operators are used by
the example.
Ex2_4 Arduino Uno Arduino serial Boolean operators in program flow
monitor of control. The reader explores the
Logical OR(II) and AND(&&) operators
along with the if() and continue
statements, so as to implement
conditional branch.
Ex2_5 Arduino Uno Temite Data input to the μC from a host
PC. The reader explores how to access
the elements of an array via either
subscripts when using loops of
predefined iterations, or pointers when
using loops of undefined iterations. In
the latter case the reader explores the
meaning of a null-terminated string, as
well as the influence of a unary
pre-increment/decrement or post-
increment/decrement operation to a
pointer. The Indirection (*), Address-of
(&), and Logical NOT (!) operators are
utilized by the example.
­Syllabu xxxvii

Table P.1 (Continued)

Lesson Example Hardware Software Description

3 Ex2_6 Arduino Uno Temite Convert numeric string to binary


value. The reader explores further the
issues learned before (i.e. inputting data
to the μC, accessing arrays with
pointers, exploiting logical operations
in the program flow of control) and, in
addition, he/she applies arithmetic
operations toward converting a numeric
string to binary value. The Arithmetic
operators of addition (+), subtraction
(−), and multiplication (*) are utilized
by the example.
Ex2_6b Arduino Uno Temite Convert binary value to numeric
string. The reader explores further the
arithmetic operations in the μC’s
memory via the opposite operation
than before. That is, by converting a
binary value to numeric string. The
conversion is performed in two steps:
(i) by applying BCD encoding to the
binary value and (ii) by converting the
BCD encoding outcome to ASCII
character. The latter task is performed
via a switch(). . .case statement. The
Arithmetic operators of division quotient
(/) and division remainder (%) are
utilized by the example.
Ex2_7 Arduino Uno Temite 2’s complement representation of
signed numbers. The reader exploits
the entry of a numeric string from the
host PC, which represents a single-byte
decimal value (i.e. from 0 to 255).
Through particular bitwise and
arithmetic operations performed by the
μC, the reader explores the signed
number representation in 2’s
complement arrangement. The method
of extracting bit information from a
variable using bitmasks, along with
bitwise tasks, is also explored.
Ex2_7b Arduino Uno Temite Multiply/Divide binary numbers to
a power of 2. The reader explores
further the bitwise operations, and in
particular the bit-shift left (<<) and
right (>>) operators, toward
multiplying a binary number with a
power of 2 (e.g. 23, 27, and so on).

(Continued)
xxxviii ­Syllabu

Table P.1 (Continued)

Lesson Example Hardware Software Description

Ex2_8 Arduino Uno Temite Code decomposition with functions.


The reader explores further how to
decompose the tasks performed by the
previous example codes, with functions.
Ex2_8b Arduino Uno Temite Code decomposition with macros.
The reader explores further the code
decomposition techniques with the use
of macros as well as the difference
between macros and functions.
4 Ex3_1 Arduino Uno — Blinking LED. The reader explores
how to provide, from the μC device, a
digital pin interface with the outside
world. Through the simplest example
of a blinking LED, the reader realizes
the rapid instruction execution by the
μC’s processor, as well as the need to
slow down particular processes,
through delay() routines, so as to
support the user interface.
Ex3_1b Arduino Uno — Blinking LED. The reader explores
further how to generate an easily
upgradable code with the use of global
variables.
Ex3_1c Arduino Uno — Blinking LED. The reader explores
further how to generate an easily
upgradable code with the use of
object-like macros as well as the space in
memory reserved by macros compared
to the global variables.
Ex3_1d Arduino Uno — Blinking LED. The reader explores
further how to generate a more
readable code with the use of functions.
Ex3_1e Arduino Uno — Blinking LED. The reader explores
further how to generate a more
readable code with the use of function-
like macros.
Ex3_2 Arduino Uno — Digital PORT interface. The reader
explores how the digital IO pins of the
Arduino Uno are grouped together and
how to concurrently access all pins of a
PORT without using Arduino-specific
functions.
Ex3_2b Arduino Uno — Digital PORT interface. The reader
explores further how to concurrently
access some, but not all pins of a PORT
without using the Arduino-specific
functions. To this end, the reader
exploits bitwise operators along with
the proper bitmasks.
Discovering Diverse Content Through
Random Scribd Documents
kasvatetaan samalla tapaa, ja monessa japanilaisessa kodissa
näkee appelsiinipuita, jotka ovat ainoastaan 15 sm korkuisia ja
kantavat kirsikan kokoisia hedelmiä.

Merkillisimpiä ilmiöitä tämän oudon tarhuritaiteen alalla oli —


kertoo edellämainittu matkustajamme — pienoinen, ainoastaan 2 ½
sm läpimitaten ja 7 ½ sm korkea ruukku, jossa kasvoi mänty,
bamburuoko ja luumupuu, viimemainittu täydessä kukassa. Tämän
harvinaisen puutarhan hinta oli 2,500 mk.

Luonnollisesti valitaan näin surkealla tavalla kidutettaviksi vain


sellaiset kasvit, jotka voivat tulla toimeen mitä epäsuotuisimmissa
olosuhteissa. Ne kaikki totutetaan mitä niukimpaan ravintoon, niin
että ne juuri voivat elää. Ja sen ohessa niitä leikellään ja taivutetaan
mitä monimutkaisimmalla tavalla, niin että ne kadottavat tykkänään
luonnollisen muotonsa ja muistuttavat kurjia rujokkaita, valoa, ilmaa
ja ravintoa vailla kasvaneita ihmisparkoja.

On otaksuttu että Japanin ilmanala on erityisen suotuisa tällaiselle


puutarhuritoimelle; ja totta onkin, etteivät Europassa tehdyt kokeet
ole tuottaneet juuri mitään sentapaisia tuloksia. Suunnatonta
kärsivällisyyttä ja taitoa siihen tarvitaan, ja epäilemättä juuri
japanilaisilla ja kiinalaisilla on ennen muita nämä ominaisuudet.
*** END OF THE PROJECT GUTENBERG EBOOK LUONNON
IHMEITÄ ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying copyright
royalties. Special rules, set forth in the General Terms of Use part of
this license, apply to copying and distributing Project Gutenberg™
electronic works to protect the PROJECT GUTENBERG™ concept
and trademark. Project Gutenberg is a registered trademark, and
may not be used if you charge for an eBook, except by following the
terms of the trademark license, including paying royalties for use of
the Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is very
easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund from
the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law in
the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms of
this agreement by keeping this work in the same format with its
attached full Project Gutenberg™ License when you share it without
charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears, or
with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in paragraph
1.F.3, the Project Gutenberg Literary Archive Foundation, the owner
of the Project Gutenberg™ trademark, and any other party
distributing a Project Gutenberg™ electronic work under this
agreement, disclaim all liability to you for damages, costs and
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving it,
you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or entity
that provided you with the defective work may elect to provide a
replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and distribution
of Project Gutenberg™ electronic works, harmless from all liability,
costs and expenses, including legal fees, that arise directly or
indirectly from any of the following which you do or cause to occur:
(a) distribution of this or any Project Gutenberg™ work, (b)
alteration, modification, or additions or deletions to any Project
Gutenberg™ work, and (c) any Defect you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
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.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like