100% found this document useful (1 vote)
458 views

Circuit Design Simulation Quick Start

The document is a quick start guide for circuit design and simulation that introduces microcontrollers. It discusses the key differences between microcontrollers and microprocessors, how they work, and their main components. Microcontrollers contain a CPU, memory, and input/output peripherals on a single chip to control embedded systems. Microprocessors require external components and have more computational power for general-purpose tasks. The guide provides an overview of microcontroller architecture, including buses, the central processing unit, and control/monitoring devices. It explains the fetch-execute cycle and discusses microcontroller types.

Uploaded by

Vitaliy Petlenko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
458 views

Circuit Design Simulation Quick Start

The document is a quick start guide for circuit design and simulation that introduces microcontrollers. It discusses the key differences between microcontrollers and microprocessors, how they work, and their main components. Microcontrollers contain a CPU, memory, and input/output peripherals on a single chip to control embedded systems. Microprocessors require external components and have more computational power for general-purpose tasks. The guide provides an overview of microcontroller architecture, including buses, the central processing unit, and control/monitoring devices. It explains the fetch-execute cycle and discusses microcontroller types.

Uploaded by

Vitaliy Petlenko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 190

MAKER

I N N O VAT I O N S
SERIES

Circuit Design
and Simulation
Quick Start
Guide
Create Schematics and Layout
Electronic Components

Ashraf Said Ahmad AlMadhoun
Maker Innovations Series
Jump start your path to discovery with the Apress Maker Innovations
series! From the basics of electricity and components through to the most
advanced options in robotics and Machine Learning, you’ll forge a path to
building ingenious hardware and controlling it with cutting-edge software.
All while gaining new skills and experience with common toolsets you can
take to new projects or even into a whole new career.

The Apress Maker Innovations series offers projects-based learning,


while keeping theory and best processes front and center. So you get
hands-on experience while also learning the terms of the trade and how
entrepreneurs, inventors, and engineers think through creating and
executing hardware projects. You can learn to design circuits, program AI,
create IoT systems for your home or even city, and so much more!

Whether you’re a beginning hobbyist or a seasoned entrepreneur working


out of your basement or garage, you’ll scale up your skillset to become a
hardware design and engineering pro. And often using low-cost and
open-source software such as the Raspberry Pi, Arduino, PIC
microcontroller, and Robot Operating System (ROS). Programmers and
software engineers have great opportunities to learn, too, as many projects
and control environments are based in popular languages and operating
systems, such as Python and Linux.

If you want to build a robot, set up a smart home, tackle assembling a


weather-ready meteorology system, or create a brand-new circuit using
breadboards and circuit design software, this series has all that and more!
Written by creative and seasoned Makers, every book in the series tackles
both tested and leading-edge approaches and technologies for bringing
your visions and projects to life.​

More information about this series at https://link.springer.com/


bookseries/17311
Circuit Design and
Simulation Quick
Start Guide
Create Schematics and Layout
Electronic Components

Ashraf Said Ahmad AlMadhoun


Circuit Design and Simulation Quick Start Guide: Create Schematics and
Layout Electronic Components

Ashraf Said Ahmad AlMadhoun


Gaza Strip, Israel

ISBN-13 (pbk): 978-1-4842-9581-6 ISBN-13 (electronic): 978-1-4842-9582-3


https://doi.org/10.1007/978-1-4842-9582-3

Copyright © 2023 by Ashraf Said Ahmad AlMadhoun


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Miriam Haidara
Development Editor: James Markham
Coordinating Editor: Jessica Vakili
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 NY
Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for
reprint, paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on the Github repository: https://github.com/Apress/Circuit-Design-and-
Simulation-Quick-Start-Guide. For more detailed information, please visit https://www.apress.
com/gp/services/source-code.
Paper in this product is recyclable.
Table of Contents
About the Author���������������������������������������������������������������������������������ix

About the Technical Reviewer�������������������������������������������������������������xi

Chapter 1: Microcontroller�������������������������������������������������������������������1
Introduction�����������������������������������������������������������������������������������������������������������1
Embedded Microcontroller������������������������������������������������������������������������������������3
Microcontroller and Microprocessor���������������������������������������������������������������������4
More on Microcontrollers and Microprocessors���������������������������������������������������9
Microcontroller: The Silent Commanders��������������������������������������������������������9
Microprocessor: The Computational Powerhouses���������������������������������������10
Symbiosis and Distinction�����������������������������������������������������������������������������11
Microcontroller and Microprocessor Comparison�����������������������������������������������12
Central Processing Unit���������������������������������������������������������������������������������������13
Machine Cycle�����������������������������������������������������������������������������������������������������14
Fetching Instruction and Its Execution����������������������������������������������������������������16
Address, Data, and Control: The Buses���������������������������������������������������������������18
Control and Monitoring Devices��������������������������������������������������������������������������20
Control Devices���������������������������������������������������������������������������������������������21
Monitoring Devices����������������������������������������������������������������������������������������21
Integration and Connectivity��������������������������������������������������������������������������22
Challenges and Considerations���������������������������������������������������������������������22
Control Devices���������������������������������������������������������������������������������������������23

v
Table of Contents

Monitoring Devices����������������������������������������������������������������������������������������24
Integration and Connectivity��������������������������������������������������������������������������24
Challenges and Considerations���������������������������������������������������������������������25
Future Prospects�������������������������������������������������������������������������������������������26
Microcontroller Types������������������������������������������������������������������������������������������26
Microcontroller: 8 Bit������������������������������������������������������������������������������������������27
Microcontroller: 16 Bit����������������������������������������������������������������������������������������29
Microcontroller: 32 Bit����������������������������������������������������������������������������������������30
Embedded Microcontroller����������������������������������������������������������������������������������32
Microcontroller with External Memory���������������������������������������������������������������34
The Architectural Specifications of Microcontroller��������������������������������������������35
Von Neumann Architecture���������������������������������������������������������������������������������37
Harvard Architecture�������������������������������������������������������������������������������������������39
Basic Principles���������������������������������������������������������������������������������������������40
Key Characteristics����������������������������������������������������������������������������������������40
Advantages����������������������������������������������������������������������������������������������������41
Applications���������������������������������������������������������������������������������������������������41
CISC (Complex Instruction Set Computer) Architecture for Microcontroller��������42
Key Characteristics and Features������������������������������������������������������������������44
Advantages of CISC Architecture for Microcontrollers����������������������������������45
Challenges and Considerations���������������������������������������������������������������������46
RISC (Reduced Instruction Set Computer) Architecture for Microcontroller�������47
SISC (Specific Instruction Set Computer) Architecture for Microcontroller���������50
Applications of Microcontrollers�������������������������������������������������������������������������51

vi
Table of Contents

Chapter 2: Basics�������������������������������������������������������������������������������57
Exporting Design in EAGLE.BRD Format�������������������������������������������������������������62
Exploring Component Manuals���������������������������������������������������������������������������62
Generating a Shareable CSV File������������������������������������������������������������������������65
Interacting with the CSV File�������������������������������������������������������������������������������66

Chapter 3: Explaining the Interface and Simulating


Your First Circuit���������������������������������������������������������������������������������69
Unveiling the Intricacies�������������������������������������������������������������������������������������69
Editing Components and Parameters������������������������������������������������������������������70
Editing Components��������������������������������������������������������������������������������������������71
Observing the Circuit’s Ensemble������������������������������������������������������������������72
Crafting a Traffic Light Application����������������������������������������������������������������72
Establishing Connections������������������������������������������������������������������������������73
The Unveiling of the Inspector�����������������������������������������������������������������������73
Bringing Realism to Your Application�������������������������������������������������������������74
Configuring Resistance Properties����������������������������������������������������������������74
Embarking on the Simulation Journey����������������������������������������������������������76
The Art of Tinkering���������������������������������������������������������������������������������������76
Exploring Resistance and Brightness������������������������������������������������������������77
Charting the Course Ahead����������������������������������������������������������������������������77
Wiring Components���������������������������������������������������������������������������������������������78
Crafting the Ensemble�����������������������������������������������������������������������������������78
Guided by Color and Practice������������������������������������������������������������������������78
A Choreography of Arrangement�������������������������������������������������������������������79
Adding Components��������������������������������������������������������������������������������������������80

vii
Table of Contents

Chapter 4: Breadboard and RGB LEDs������������������������������������������������85

Chapter 5: Ohm’s Law�������������������������������������������������������������������������91

Chapter 6: Series and Parallel Circuits�����������������������������������������������97

Chapter 7: Arduino Output Basics����������������������������������������������������107


Arduino Digital Output: LED Control������������������������������������������������������������������107
Arduino Dealing with Multiple LEDs and Breadboard���������������������������������������112
Arduino Analog Output: Fading LED������������������������������������������������������������������117

Chapter 8: Arduino Input Basics�������������������������������������������������������129


Reading Digital Input�����������������������������������������������������������������������������������������130
Reading Analog Value����������������������������������������������������������������������������������������137

Chapter 9: Dealing with RGB LED with Potentiometers��������������������147

Chapter 10: Arduino Serial Monitor��������������������������������������������������163


Conclusion: Navigating the Circuit Design Odyssey������������������������������������������171
Exploring Boundless Horizons: Beyond Circuit Design and Simulation�������������173

Index�������������������������������������������������������������������������������������������������177

viii
About the Author
Ashraf Said Ahmad AlMadhoun is an educator, a mechatronics engineer,
an electronics and programming hobbyist, and a maker. He hosts the
popular EduEng YouTube channel and has authored four books on
microcontrollers. As a Chief Educational Engineer since 2007 for the
Educational Engineering Team, a company he founded, Ashraf’s mission
is to explore new trends and technology and help educate the world and
make it a better place. Educational Engineering offers educational courses
and bootcamps, articles, lessons, and online support for electronics
hobbyists, programming hobbyists, microcontroller hobbyists, STEM
students, and teachers. His passion for microcontrollers and programming
and in particular for the world of Arduino, PIC microcontroller, and the
Raspberry Pi has guided his personal development and his work through
Educational Engineering.

ix
About the Technical Reviewer
Massimo Nardone has more than 22 years
of experience in security, web and mobile
development, cloud, and IT architecture. His
true IT passions are security and Android. He
has been programming and teaching how to
program with Android, Perl, PHP, Java, VB,
Python, C/C++, and MySQL for more than
20 years. Massimo also holds a master of
science degree in computing science from the
University of Salerno, Italy. He has worked as
a project manager, software engineer, research engineer, chief security
architect, information security manager, PCI/SCADA auditor, and senior
lead IT security/cloud/SCADA architect for many years. His technical
skills include security, Android, cloud, Java, MySQL, Drupal, Cobol, Perl,
web and mobile development, MongoDB, D3, Joomla, Couchbase, C/C++,
WebGL, Python, Pro Rails, Django CMS, Jekyll, Scratch, etc. Massimo also
worked as visiting lecturer and supervisor for exercises at the Networking
Laboratory of the Helsinki University of Technology (Aalto University). He
holds four international patents (PKI, SIP, SAML, and Proxy areas).

xi
CHAPTER 1

Microcontroller
Introduction
In the vast landscape of technological innovation, microcontrollers emerge
as the unsung champions orchestrating a symphony of digital wonders
that shape our modern lives. These unassuming yet powerful devices have
left an indelible mark on our world, influencing everything from our daily
routines to the intricate machinery that drives industries forward. The
journey of microcontrollers is one of transcending boundaries, seamlessly
blending into the fabric of our existence while simultaneously driving
progress and innovation.
Picture this: You enter a bustling restaurant, the rhythmic clatter of
cutlery and the warm ambience enveloping you. Little do you know that
microcontrollers silently facilitate the swift transactions at the cash register,
ensure the precision of weighing scales, and even manage the ambient lighting
that sets the mood. These ubiquitous data processors quietly synchronize
each element, enhancing your experience without seeking recognition.
In the realm of domestic comfort, microcontrollers continue to weave
their magic. They are the enigmatic brains behind your oven, meticulously
preparing your meals to perfection, and the washer/dryer, expertly
handling your laundry with care. Not to be overlooked, the trusty alarm
clock that gently rouses you from slumber is another creation indebted to
these miniature powerhouses.

© Ashraf Said Ahmad AlMadhoun 2023 1


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_1
Chapter 1 Microcontroller

As you dive further into the world of entertainment, microcontrollers


reveal their versatility once again. Toys spring to life under their guidance,
VCRs spin tales of cinematic delight, and stereo systems amplify emotions
through sound. Even in corporate settings, they remain indispensable,
managing everything from the rhythmic keystrokes of keyboards to the
ceaseless operation of copy machines and escalators.
Industry, too, bows to the prowess of microcontrollers. They serve as
the bedrock of automation, ensuring that factories hum with efficiency
and safety. Their reach extends to the intricate systems that grace your
automobile, from stop signs to complex automotive systems, enhancing
both safety and performance.
But what constitutes the essence of these digital maestros? Enter
the microcontroller, an embodiment of complexity distilled into a
compact form. Differing from their more recognized counterparts, the
microprocessors, microcontrollers are specialized for a spectrum of
tasks, often tailored to excel in a particular domain. They are versatile,
multifaceted, and possess the unique ability to process, store, and execute
instructions, all while interfacing with a plethora of peripherals.
This chapter stands as the gateway to understanding this intricate
universe of microcontrollers. It beckons you to explore their nuances,
distinguishing them from the larger microprocessors that often hog the
spotlight. Beyond this introduction, a labyrinthine world of commercial
microcontrollers awaits, each offering its own set of capabilities and
potential. As you embark on this journey, you’ll navigate the realm of
microcontrollers, unearthing their potential through programming and
unveiling strategies to interface with them.
In essence, microcontrollers are the unsung architects of our digital
lives, embedding intelligence and sophistication into devices that surround
us. The art lies in deciphering their intricacies, selecting the perfect tool for
a specific task, and harnessing their potential through skillful programming.
So, let us delve deeper, peeling back the layers of these unassuming devices
to reveal the brilliance and innovation that they bestow upon our world.

2
Chapter 1 Microcontroller

Embedded Microcontroller
An embedded controller is an integral component within a broader
system, playing a crucial role in managing and directing specific
functionalities of the overall device. This specialized computing unit is
intricately woven into the fabric of the device, geared toward executing a
particular function beyond the realm of general-purpose computing. It is
imperative to differentiate between the terms “embedded controller” and
“microcontroller,” as the former encompasses a wider array of computing
entities that extend beyond the latter’s boundaries.
Microcontrollers are a subset of embedded controllers, encompassing
a specific category of computing devices characterized by their
compactness, integration of processing, memory, and input/output
components onto a single chip. While the terms are sometimes used
interchangeably, it’s essential to recognize that not all embedded
controllers fit the microcontroller mold. The 68000, 32032, and x86
are prime examples of embedded controllers that don’t fall under the
microcontroller umbrella due to their larger scale and more versatile
computing capabilities.
The scope of an embedded controller’s responsibilities is impressively
diverse. These controllers oversee an assortment of tasks, ranging from the
intricate regulation of household appliances like microwave ovens to the
intricate management of critical systems such as car braking mechanisms
or even military-grade hardware like cruise missiles. This capacity for
multifaceted control showcases the adaptability of embedded controllers
in responding to vastly different operational requirements.
One common thread shared between microcontrollers and embedded
controllers is their effective utilization of on-chip resources. By capitalizing
on the integrated capabilities of their hardware components, these
controllers streamline their operations, contributing to optimized
performance and efficient resource management. The symbiotic
relationship between hardware and software intricately woven into

3
Chapter 1 Microcontroller

the design of embedded controllers enables them to achieve seamless


coordination and real-time response in executing their designated
functions.
The landscape of embedded systems is remarkably rich and varied,
often leveraging both microcontrollers and microprocessors to accomplish
their objectives. While microcontrollers maintain a predominant presence
due to their energy-efficient characteristics, microprocessors also find
relevance in scenarios where more computational power is required.
The selection between microcontrollers and microprocessors hinges on
the specific needs of the embedded system, guided by considerations
such as power consumption, computational complexity, and real-time
responsiveness.
In conclusion, an embedded controller operates as the linchpin
within a complex web of devices, exerting specialized control over distinct
functions that extend far beyond the realm of traditional computing.
The distinction between embedded controllers and microcontrollers is
critical, as the former encapsulates a broader spectrum of computing
entities. The embodiment of an embedded controller’s capabilities is
showcased in its role as the orchestrator of tasks spanning from everyday
conveniences to high-stakes systems, all united by the mastery of on-chip
resources. This dynamic landscape harmonizes both microcontrollers
and microprocessors, optimizing their contributions based on the unique
demands of each embedded system.

Microcontroller and Microprocessor


The intricate task of orchestrating and supervising a process finds its
fulfillment through the adept utilization of a controller, a masterful
conductor of various operations. In a bygone era, controllers emerged as
substantial and unwieldy constructs, bearing witness to a time when their
creation rested solely upon the assembly of logic components. However,

4
Chapter 1 Microcontroller

the landscape underwent a dramatic metamorphosis with the assimilation


of microprocessors, an evolution that ushered in a new era where an entire
controller could be seamlessly encapsulated onto a solitary circuit board.
Even amidst the modern technological panorama, a diverse
assortment of controllers continues to harness the computational might
offered by a myriad of microprocessors, each wielding distinct attributes
and capabilities. Within this vibrant tapestry, prominent figures such as
the Zilog Z80, Intel 8088, Motorola 6809, and an array of other contenders
stand as embodiments of technological prowess, contributing their unique
strengths to the rich tableau of controller innovation.
As the march of progress continued, the trend toward miniaturization
took center stage, leading to a watershed moment where all constituent
elements of a controller converged onto a single microchip. This marked
the genesis of the microcontroller, often colloquially referred to as a “one-­
chip computer,” encapsulating a harmonious symphony of functionalities
within a remarkably diminutive package. It is worth noting that the
nomenclature “microprocessor” is expressly reserved for the central
processing unit (CPU) seamlessly integrated onto a solitary Very Large
Scale Integration (VLSI) chip, encapsulating prodigious computational
prowess within its compact confines.
A perusal of Figure 1-1 reveals a simplified yet comprehensive block
diagram of a CPU, offering a glimpse into the intricate choreography of
operations transpiring within its silicon heart. Nestled within this compact
chip are a plethora of essential components, ranging from the Arithmetic
Logic Unit (ALU) that executes mathematical and logical operations to the
Instruction Decode and Control Unit that choreographs the execution of
instructions. An Instruction Register, Program Counter (PC), clock circuit
for synchronization, reset circuit for initializing states, and a constellation
of ancillary components further enrich the composition of this microcosm.
This microprocessor realm encompasses an array of specifications, boasting
8-bit exemplars like the Intel 8085 and 16-bit counterparts such as the Intel
8086/8088, each calibrated to cater to specific computational demands.

5
Chapter 1 Microcontroller

Figure 1-1. Microprocessor block diagram

At its core, the central processing unit (CPU) of a microprocessor stands


as a versatile, digital titan, proficient in executing an expansive gamut of
tasks. This versatile entity constitutes the bedrock of a microcomputer,
a marvel constructed by amalgamating a general-purpose CPU with an
ensemble of peripheral hardware. This fusion of CPU and peripherals
empowers microcomputers with the versatility to traverse a broad spectrum
of computing endeavors, thus emerging as adaptable, multifunctional tools
poised to navigate a myriad of contexts and requirements.
The term “microcomputer” encapsulates the essence of a digital
computing system where a microprocessor takes center stage as the
central processing unit (CPU), synergizing seamlessly with input/output
devices and memory resources. This amalgamation creates a holistic
computational entity that finds its embodiment in the digital landscape.
The intricate structure of a microcomputer finds representation in the
block diagram illustrated in Figure 1-2, delineating the orchestration of its
constituent elements.

6
Chapter 1 Microcontroller

Figure 1-2. Block diagram of microcomputer

The microcomputer realm, however, intersects with the domain


of microcontrollers, which are exemplified by integrated chips. These
microcontrollers epitomize compact marvels, incorporating a comprehensive
suite of components necessary for the functioning of a controller onto a
solitary chip. Beyond the central processing unit (CPU), a tapestry of integral
features coalesces, encompassing Random Access Memory (RAM), Erasable
Programmable Read-Only Memory (EPROM)/Programmable Read-Only
Memory (PROM)/Read-Only Memory (ROM), and a dynamic array of input/
output (I/O) capabilities that encompass both serial and parallel paradigms.
This ensemble extends further to include timers that govern temporal
precision and interrupt controllers that facilitate seamless transitions
between different processing tasks. Microcontrollers possess an innate ability
to assimilate these features into their architecture, culminating in a holistic
and self-­contained control solution.

7
Chapter 1 Microcontroller

As a testament to the diversity within the microcontroller spectrum,


notable instances emerge to illuminate this landscape. The Intel 8051
stands as an exemplar of an 8-bit microcontroller, harnessing its compact
architecture to achieve intricate control tasks. In contrast, the Intel 8096
emerges as a 16-bit microcontroller, harnessing enhanced computational
capabilities to navigate more complex computational demands. These
distinctions, while nuanced, underscore the intricate interplay between
microcontrollers’ architecture and their specific applications.
In essence, the convergence of microcomputers and microcontrollers
underscores the dynamism within the realm of digital computing. The
microcomputer stands as a versatile hub where microprocessors coalesce
with memory and input/output functions to enable a broad spectrum of
computational endeavors. On the other hand, microcontrollers represent
the epitome of compact integration, harmonizing a suite of pivotal
components on a singular chip, thus endowing them with the capacity
to orchestrate intricate control processes. The alignment between these
two constructs provides a multifaceted toolkit for addressing diverse
computational requirements.
The economic advantage inherent in microcontrollers is manifest
in their modest cost, as they encapsulate solely the essential elements
requisite for their designated task of control. This streamlined approach
ensures that extraneous components are excluded, leading to a resource-­
efficient solution tailored to the specific task at hand. Microcontrollers, by
design, often incorporate specialized instructions for bit manipulation,
thereby facilitating nuanced control over individual bits within registers.
Additionally, they exhibit direct access to input/output (I/O) operations,
enabling seamless read and write interactions with peripheral devices. The
integration of efficient interrupt processing capabilities further amplifies
their utility, enabling rapid transitions between different tasks and
ensuring real-time responsiveness.

8
Chapter 1 Microcontroller

A microcontroller’s architecture finds visual articulation in the block


diagram showcased in Figure 1-3. This diagram presents a coherent
representation of the intricate interplay between the microcontroller’s
constituent components, offering a window into the underlying mechanics
of its functionality.
This synergy between architecture and functionality within
microcontrollers underscores their pivotal role in the realm of digital
control. By judiciously incorporating only the components necessary
for a specific task, microcontrollers strike a balance between resource
optimization and targeted performance. This approach ensures that
each microcontroller stands as a specialized entity, armed with tailored
capabilities that empower it to meet the unique demands of its assigned
control responsibilities.

More on Microcontrollers
and Microprocessors
Microcontroller: The Silent Commanders
Imagine a device that not only processes data but also interacts with the
physical world, executing a predefined set of tasks with precision and
finesse. Enter the microcontroller, a versatile yet compact computing
marvel that operates as a self-contained system on a chip (SoC). At its core,
a microcontroller encapsulates a central processing unit (CPU), memory,
input/output (I/O) ports, and often other essential peripherals.
Microcontrollers are the architects of embedded systems, orchestrating
a symphony of tasks in devices that span from consumer electronics
to industrial automation. Their design philosophy revolves around
specialization; they are tailored to excel in specific applications, optimizing
power consumption, size, and cost. Microcontrollers are the workhorses
behind the scenes, executing dedicated functions without the need for
external support.

9
Chapter 1 Microcontroller

Intricacies aside, the beauty of microcontrollers lies in their real-world


application. They power your smart home devices, regulate temperature
in thermostats, guide the automation of manufacturing lines, and
even navigate your car’s intricate systems. With their diverse range of
functionalities, microcontrollers bring an unparalleled level of intelligence
to devices that surround us, ensuring efficiency, accuracy, and interaction.

Microprocessor: The Computational


Powerhouses
While microcontrollers epitomize efficiency and specialization,
microprocessors stand as computational powerhouses, capable of
executing complex algorithms and handling large amounts of data.
These components, the brainchildren of Moore’s Law, boast immense
processing power, making them the go-to choice for general-purpose
computing tasks.
Microprocessors are often found at the heart of computers, laptops,
and servers, performing tasks ranging from browsing the web to running
intricate simulations. Their architecture consists of arithmetic logic units
(ALUs), control units, and caches, meticulously designed to handle the
intricate dance of data manipulation, storage, and control.
In the realm of personal computing, microprocessors enable
multitasking, rapid data processing, and seamless user experiences.
These processors are not limited by specialization; rather, they thrive on
adaptability and the ability to handle a vast array of applications.

10
Chapter 1 Microcontroller

Symbiosis and Distinction


The relationship between microcontrollers and microprocessors is both
symbiotic and distinct. While microcontrollers cater to the embedded
world, microprocessors rule the domain of general-purpose computing.
Their symbiosis emerges in scenarios where both are integrated into a
system, with the microcontroller handling specific real-world tasks and the
microprocessor managing higher-level computation.
As technology advances, the boundary between these entities blurs,
with some microcontrollers embracing more powerful processing
capabilities and microprocessors incorporating specialized features for
specific applications. This fusion expands their applicability, offering
greater flexibility and efficiency.
In summary, microcontrollers and microprocessors epitomize the essence
of modern computing. They drive innovation, shape industries, and enrich
our lives in ways that often go unnoticed. Microcontrollers, through their
specialization, bring intelligence to embedded systems, while microprocessors
provide the computational muscle needed for diverse applications.
Together, they form the backbone of a digital world that continues to evolve,
empowering us to navigate the complexities of the modern age.

Figure 1-3. Microcontroller block diagram

11
Chapter 1 Microcontroller

Microcontroller and Microprocessor


Comparison
• All of the circuitry needed to build a complete
microcomputer can be found on a single chip in a
microprocessor.

• Additional hardware such as an interrupt scheduler


and timer are included in the microcontroller, which is
a single chip.

• Although it is less than a typical microcomputer’s


RAM, this amount is plenty for the programs that will
run on it.

• Microcontrollers must be able to react immediately


to control-oriented devices, which necessitates
the use of interrupt systems. When the door of a
microwave oven is opened, for example, the operation
is halted. An external component is usually required
for most microprocessors to implement powerful
interrupt schemes. As the CPU in microcomputers,
microprocessors are the most popular choice. The use
of microcontrollers in small, low component designs for
control-oriented activities has become commonplace.

• Processing-intensive microprocessor instruction sets


need high-capacity addressing modes and instructions
that can handle enormous amounts of information.
A byte is a single unit of measurement used by these
programs. Inputs and outputs are controlled by
instruction sets on microcontrollers. A single bit is all it
takes to execute their instructions. A 1-bit output port
may be used to switch a motor on and off, for example.

12
Chapter 1 Microcontroller

Before delving into the specifics of microcontrollers, it’s a good idea to


brush up on some of the most often used terms.

Central Processing Unit


At the heart of the computer system resides the formidable Central
Processing Unit (CPU), an intricate electronic marvel that stands as the
supreme conductor orchestrating a symphony of system activities with
unparalleled finesse. This commanding entity not only presides over the
entire computational landscape but also dons the mantle of executing
a myriad of data operations, breathing life into the system’s inherent
potential. Operating ceaselessly like the pulsating heart of the system,
the CPU stands unwavering in its dedication to the perpetual cycle of
obtaining and executing commands, embodying a perpetual dance that
fuels the system’s operational prowess.
Within this grand choreography, the CPU’s command interpretation
and execution prowess hinge upon its mastery of an intricate lexicon:
the instruction set. This compendium of binary codes serves as the very
language that the CPU fluently speaks and comprehends, functioning
as a bridge between human intent and machine action. Through the
instruction set’s artful assembly of binary codes, the CPU deciphers
the nuanced intentions embedded within commands, unraveling their
complexities with unerring precision. With each execution, the CPU
embarks upon an eloquent ballet of transforming abstract notions
into tangible actions, rendering the digital realm a canvas for human
aspirations to unfold.
The ceaseless interplay between the CPU, its commanding instruction
set, and the vast spectrum of data operations paints a tapestry of
computational prowess. Each binary command is akin to a brushstroke
upon this canvas, conveying not just mathematical manipulations but
a symphony of intentions and desires. As the CPU tirelessly navigates

13
Chapter 1 Microcontroller

its role as the digital maestro, it transforms these commands into a


seamless symphony of logic and action, unfurling the limitless potential
that lies within the realm of computing. The intricate ballet of command
interpretation, execution, and result generation underscores the CPU’s
central role as the linchpin of computational endeavors, propelling the
digital universe forward with every flicker of its electronic pulse.

Machine Cycle
Embarking upon the journey of executing a command, the processor
traverses a carefully choreographed sequence of phases, each imbued with
its own unique significance. This intricate symphony of computational
activity commences with a poignant first act:

• Instruction Retrieval: Within the vast expanse of


memory, the sought-after command finds its abode.
Herein, nestled amidst a sea of data lies the instruction
waiting to be brought to life. As the processor awakens,
it casts its gaze upon the memory’s tapestry, seeking
the elusive code that shall guide its next steps.

Having procured the instruction, the processor embarks upon the


second movement:

• Instruction Decoding: The instruction, often cryptic


in its binary form, holds the blueprint of the task at
hand. It is the processor’s role to imbue these binary
whispers with meaning, meticulously translating them
into a sequence of actions to be undertaken. In this act
of decipherment, the processor wields its intellect to
grasp the very essence of the command.

14
Chapter 1 Microcontroller

With the essence of the instruction now unveiled, the processor


proceeds to the third act:

• Execution of Command: The heart of the matter lies


here—where commands metamorphose into actions.
Guided by the now-comprehended instruction, the
processor navigates a labyrinth of logic gates and
data pathways, orchestrating the dance of electrons
that engenders the desired outcome. In this ballet of
data manipulation, the processor becomes an artist,
breathing life into the digital canvas.

As the final crescendo approaches, the processor enters the


penultimate movement:

• Result Recall and Memory Update: The fruits of the


executed command, tangible in their numerical
essence, are embraced by the processor’s grasp. These
results, a testament to its computational prowess, are
etched into memory, a testament to the journey that
has transpired. The memory banks, once tranquil,
now bear witness to the transient passage of data,
preserving the echoes of digital accomplishment.
The culmination of these four carefully choreographed movements
births the machine cycle, an elegant construct that defines the rhythm of
computational endeavors. It is in this rhythmic cycle that the processor
experiences its moments of inception, comprehension, execution, and
preservation. In the intricate dance of the machine cycle, the processor
finds its raison d’être.
Yet, the tempo of this dance is not set in stone. It is shaped by the clock
cycle, the pulse that governs the processor’s every move. In most scenarios,
one machine cycle resonates with X clock cycles, where X is a value
contingent upon the specific command in play. A shorter clock cycle, a

15
Chapter 1 Microcontroller

swifter beat, leads to a briefer machine cycle—a testament to the efficiency


with which instructions are transmuted into action. Thus, the processor’s
cadence directly influences the pace of computation, with a rapid clock
cycle yielding a CPU that races through tasks with unbridled swiftness, a
digital sprinter poised to conquer the challenges of modern computing.

Fetching Instruction and Its Execution


Unfurling the veiled intricacies of the fetching process, one discovers
a sequence orchestrated with remarkable precision—a harmonious
symphony of electronic gestures woven into the fabric of computation.
This symphony commences with the initial movement:

• Address Retrieval and Connection: At the dawn of this


process, the spotlight shines upon the contents residing
within the Program Counter (PC), a numeric sentinel
pointing toward the next destination in the digital
landscape. These contents, brimming with potential,
are elegantly connected to the address bus—a
metaphorical conduit that guides the processor to its
intended memory address.

With the address in hand and the stage set, the process advances to the
second act:

• Read Activation: In a pivotal moment, the signal


“READ” echoes through the system, a clarion
call summoning the retrieval of data. This signal
illuminates the pathways, directing the processor’s
gaze toward the Random Access Memory (RAM) where
sought-after treasures lie dormant.

16
Chapter 1 Microcontroller

As the memory doors open, the third stanza unfolds:

• Data Extraction and Transmission: The RAM yields its


bounty—a symphony of bits forming an instruction
opcode—transmitting it to the data bus, an intricate
network akin to digital synapses. Within this matrix,
the data makes its journey, coursing through digital
veins, poised to bestow meaning upon the upcoming
endeavors.

The fourth movement, marked by finesse, awaits:

• Opcode Lodging in the Instruction Register: Like a


key sliding into a lock, the opcode—now endowed
with significance—gracefully finds its place within the
internal instruction register of the CPU. This hallowed
vessel becomes the cradle for the instruction’s essence,
a reservoir from which actions will emanate.

And as this tableau approaches its culmination, the final note


reverberates:
Program Counter Advancement: The Program Counter, once an
emblem of the past, now rises to meet the future. Elevated by the very act
it catalyzed, the PC readies itself for the forthcoming memory retrieval,
its numeric fingerprint ever-evolving to shepherd the processor along its
computational odyssey.
However, this process transcends mere form; its substance finds
its roots in the ALU—Algebraic Logic Unit—a nexus of computation.
During execution, the ALU’s internal registers engage in a complex dance,
their graceful entrance and exit orchestrated in perfect harmony. As the
choreography unfolds, a decisive command resonates—a siren’s call that
prompts the ALU to set its gears in motion, embarking upon the specified
action with meticulous precision.

17
Chapter 1 Microcontroller

In this grand symphony of electronic ballet, fetching emerges as a


fundamental passage—a prelude that sets the stage for the forthcoming
computational symphony. Its interplay of gates, signals, and data pathways
forms the tapestry upon which the processor’s every action rests—a digital
overture that heralds the dawn of computation’s intricate narrative.

Address, Data, and Control: The Buses


• The digital tapestry of information transmission is
intricately woven through the existence of a BUS—a
congregation of cables, each a lifeline transmitting
data, collectively bound by a shared purpose. In this
symphony of connectivity, a BUS emerges as the
conductor orchestrating the harmonious exchange
of digital messages, nurturing the network’s vitality.
Within this expansive landscape, a rhythmic cadence
emerges as the CPU conducts its dialogue with the
memory, a sequence that unfurls as follows:

• Addressing and Control: In the first movement,


the CPU steps onto the stage, bearing in hand the
key to the memory’s treasury—a numeric address
brimming with intent. With deliberation, the CPU
imparts this address onto the address bus—a
conduit of purpose that guides the data’s journey.
Concurrently, the control bus vibrates with signals,
conveying the nature of the CPU’s query—be it a
quest for insight through reading or a directive to
inscribe through writing.

18
Chapter 1 Microcontroller

• As the address and signals traverse the digital avenues,


a second act takes center stage:

• READ Operation: With the address bestowed


upon the address bus, the memory’s portal is
unlocked, yielding a byte of data in response to the
CPU’s inquiry. This operation is akin to plucking
a carefully chosen note from a symphonic score.
The retrieved data embarks on a journey—a digital
odyssey—transiting from the memory through
the CPU’s data bus, a channel carved for the very
purpose of this exchange.

• Within the CPU’s inner sanctum, a third movement


commences:

• Data Repository and Retrieval: As the data alights


within the CPU’s domain, an internal register steps
forward—a keeper of the retrieved byte, a guardian
entrusted with safeguarding the essence of the
memory’s offering. This register deftly stores the
retrieved data, ensuring it remains within reach,
poised to infuse computational endeavors with
newfound meaning.

• And as the tale approaches its zenith, the final


movement unfolds:

• WRITE Operation: When the CPU aspires to


inscribe its digital essence into the memory’s
annals, it bequeaths its data onto the data bus—a
conveyor for its transformative message. With
grace, the data traverses the digital byways,

19
Chapter 1 Microcontroller

reaching its destined station within the memory.


Here, ensconced amidst the memory’s chambers,
the data nestles, its presence etched into the
memory’s fabric, ready to influence future
computational symphonies.

• In essence, the BUS—an ethereal web of cables—acts


as a bridge for digital interaction, forging a communion
between the CPU and memory. Each interaction is a
carefully choreographed pas de deux—a dance of digital
dialogue that shapes the narrative of computation. As
the CPU raises its address, signals resonate, and data
journeys, the BUS manifests its role as the lifeblood of
digital connectivity—a pulsating force underpinning the
symphony of information exchange.

Control and Monitoring Devices


• If a voltage or current is applied to a control device, it
may have an effect on the environment.

• It is the responsibility of monitoring devices to


transform the signals generated by sensors such as
these into voltages or currents that can be read by a
computer.

Control and monitoring devices play a pivotal role in modern technology,


shaping the way we interact with machines, systems, and processes. These
devices bridge the gap between human intention and the functioning
of various devices, enabling us to manipulate and oversee complex
operations with ease and precision. Their applications are ubiquitous,
spanning industries such as manufacturing, healthcare, transportation,
energy, and beyond.

20
Chapter 1 Microcontroller

Control Devices
Control devices are designed to influence the behavior of machines,
equipment, or systems according to specific requirements or commands.
They empower users to direct processes, adjust parameters, and initiate
actions. These devices act as the interface through which human input is
translated into actionable commands for machines to execute.
One common example of a control device is the remote control used
to manage televisions, home theaters, and other entertainment systems. It
allows users to change channels, adjust volume, and navigate menus, all
from a comfortable distance. In industrial settings, control panels are used
to oversee manufacturing lines, regulating speed, temperature, and other
critical factors to ensure optimal product quality and efficiency.
Advanced control devices, such as Programmable Logic Controllers
(PLCs), are widely employed in industrial automation. PLCs are
programmable devices that can execute complex sequences of operations
based on input from sensors, switches, and other devices. They enable
real-time adjustments, error detection, and consistent execution of tasks
without human intervention.

Monitoring Devices
Monitoring devices are designed to collect, display, and convey
information about the status, performance, or condition of a system,
process, or environment. They provide critical insights to users, enabling
them to make informed decisions and take appropriate actions based on
real-time data.
Consider environmental monitoring devices, such as weather
stations, which measure temperature, humidity, wind speed, and other
atmospheric conditions. This data is essential for predicting weather
patterns, studying climate trends, and making informed decisions related
to agriculture, construction, and disaster management.

21
Chapter 1 Microcontroller

In the healthcare sector, wearable fitness trackers monitor heart rate,


steps taken, sleep patterns, and more. These devices empower individuals
to track their well-being and make adjustments to their lifestyle for
improved health outcomes.
Industrial sectors benefit from monitoring devices as well. Sensors
placed in machinery can monitor vibrations, temperature, pressure, and
other indicators, enabling predictive maintenance. By analyzing data from
these sensors, companies can anticipate equipment failures and schedule
maintenance before critical failures occur, minimizing downtime and
optimizing efficiency.

Integration and Connectivity


Modern control and monitoring devices are often equipped with
connectivity features, enabling them to communicate with other devices,
systems, and the cloud. This integration allows for centralized management,
remote control, and data analysis. The Internet of Things (IoT) has amplified
the capabilities of control and monitoring devices, enabling seamless
communication and data exchange between devices and applications.

Challenges and Considerations


While control and monitoring devices offer immense benefits, their design
and deployment come with challenges. Ensuring data security, especially
in interconnected systems, is paramount to prevent unauthorized access
or data breaches. Moreover, designing user interfaces that are intuitive and
user-friendly is essential for effective human-device interaction.
In conclusion, control and monitoring devices have revolutionized
the way we interact with our surroundings, offering unparalleled control,
insights, and efficiencies across various domains. As technology continues
to advance, these devices will play an increasingly vital role in shaping the
way we manage and optimize complex processes and systems.

22
Chapter 1 Microcontroller

Control and monitoring devices are foundational components in the


realm of automation, enabling us to manipulate, supervise, and optimize
various systems and processes. Their significance extends across diverse
industries, from manufacturing and energy to healthcare and smart
homes. Let’s delve deeper into the concepts, types, integration, challenges,
and future prospects of these devices.

Control Devices
Control devices facilitate human intervention in the operation of
machines, equipment, and systems. They can be as simple as switches
and buttons or as complex as advanced industrial controllers. Examples
include

• Switches and Buttons: These basic control elements


allow users to turn devices on/off or trigger specific
functions. From light switches to elevator buttons,
these ubiquitous components provide direct control.

• Thermostats: Used in heating, ventilation, and


air conditioning systems, thermostats maintain
temperature settings by regulating heating/cooling
equipment based on user preferences.

• Motor Controllers: These devices manage the speed


and direction of motors. Variable Frequency Drives
(VFDs) are commonly used in industrial settings to
control motor speed and energy consumption.

• Programmable Logic Controllers (PLCs): PLCs are


specialized computers programmed to automate
industrial processes. They monitor sensors and
inputs, execute logic, and control outputs to optimize
manufacturing operations.

23
Chapter 1 Microcontroller

Monitoring Devices
Monitoring devices gather data from sensors and present it in
a comprehensible format for analysis and decision-making.
Examples include

• Sensors: These devices detect changes in physical


properties like temperature, pressure, humidity, and
light. They provide real-time data that forms the basis
of monitoring systems.

• Data Loggers: These devices record data over time


for analysis and trending. They are useful for tracking
environmental conditions, energy consumption, and
equipment performance.

• Cameras and Surveillance Systems: Video cameras


capture visual information for security and surveillance
purposes. Advanced systems use computer vision
and artificial intelligence to analyze scenes and detect
anomalies.

• Medical Monitors: Used in healthcare, these devices


track vital signs, such as heart rate, blood pressure, and
oxygen levels. They provide clinicians with real-time
patient information for diagnosis and treatment.

Integration and Connectivity


Control and monitoring devices are increasingly equipped with
connectivity features that enable them to communicate with other devices
and systems. This interconnectedness enables

24
Chapter 1 Microcontroller

• Remote Control: Users can operate devices and systems


remotely, enhancing convenience and efficiency. Smart
home devices, for example, allow users to control
lights, thermostats, and appliances via smartphones.

• Data Sharing: Devices can exchange data with each


other and with cloud-based platforms. This enables
central data storage, analysis, and insights, fostering
informed decision-making.

• Automation: Integrated systems can trigger actions


automatically based on predefined conditions. For
instance, a temperature sensor can activate a cooling
system when the temperature exceeds a threshold.

Challenges and Considerations


As control and monitoring devices become more sophisticated, several
challenges emerge:

• Security: Ensuring data confidentiality and protecting


against unauthorized access is crucial. Vulnerabilities
in connected devices can lead to data breaches and
compromises.

• Usability: Designing intuitive user interfaces is vital


for effective human-device interaction. Users should
be able to easily understand and navigate control and
monitoring interfaces.

• Interoperability: In interconnected ecosystems, devices


from different manufacturers need to communicate
seamlessly. Industry standards and protocols help
ensure compatibility.

25
Chapter 1 Microcontroller

Future Prospects
The future of control and monitoring devices holds promising
developments:

• Artificial Intelligence: Integration of AI will enable


devices to learn from data, make predictions, and
automate decisions based on complex patterns.

• Edge Computing: Devices will process data locally


(at the “edge” of the network) to reduce latency and
reliance on cloud services, enhancing real-time
decision-making.

• 5G Connectivity: The rollout of 5G networks will enable


faster and more reliable communication between
devices, enabling new applications and use cases.

In conclusion, control and monitoring devices are integral to modern


life and industries. Their continuous evolution will shape the landscape
of automation, enhancing efficiency, safety, and convenience across
various sectors. As technology advances, these devices will become more
intelligent, interconnected, and integral to the seamless functioning of our
complex world.

Microcontroller Types
The internal bus width, architecture, memory, and instruction set of
microcontrollers may be used to categorize them. Figure 1-4 shows the
many microcontrollers available.

26
Chapter 1 Microcontroller

Figure 1-4. Microcontroller types

Microcontroller: 8 Bit
In the realm of computational orchestration, a pivotal player takes
the stage—the microcontroller—a digital virtuoso designed to
seamlessly execute intricate commands with finesse. Among the ranks
of microcontrollers, an 8-bit microcontroller stands as a remarkable
manifestation of computational prowess, its ALU—an Algebraic Logic
Unit—wielding its arithmetic and logical acumen with remarkable
precision upon 8-bit bytes. This dexterity ensures that operations
unfurl upon a canvas composed of 8 bits, a realm that caters to the fine
granularity of data manipulation.

27
Chapter 1 Microcontroller

This embodiment of computational elegance encompasses not only


the ALU’s capabilities but also extends to the internal bus width—a digital
thoroughfare that navigates the microcontroller’s inner realms. In the
domain of 8-bit microcontrollers, the internal bus width is a harmonious
8 bits wide, mirroring the domain upon which the ALU operates. This
symbiosis between ALU and bus width bestows a sense of unity to the
microcontroller’s inner workings, each element aligned in pursuit of
computational brilliance.
Stepping into the pantheon of microcontroller legends, exemplars
emerge that embody the essence of 8-bit microcontrollers. Among
these, the Intel 8051 series radiates its impact with resounding clarity, its
architecture and capabilities painting a portrait of digital prowess that
has left an indelible mark on the computational landscape. Motorola’s
MC68HC11 series, equally illustrious, stands as another sentinel of 8-bit
excellence, its influence resonating through the annals of microcontroller
history.
Beyond their discrete implementations, 8-bit microcontrollers
represent more than just units of computation; they are the embodiment
of digital artistry. The choreography of bits and the interplay of logic gates
harmonize within their circuitry, giving rise to a symphony of control
and precision. These microcontrollers materialize as the conductors of
digital symphonies, orchestrating data’s intricate dance and harmonizing
operations with unparalleled grace.
With every byte manipulated, every gate traversed, 8-bit
microcontrollers infuse the digital realm with a sense of calculated
elegance. As they thread the fine line between efficiency and versatility,
their influence extends far beyond mere computational boundaries. They
are the architects of automated symphonies, the architects of digital logic’s
triumphs, and the heralds of a new era in control and precision. The legacy
of these 8-bit marvels is etched into the very fabric of computational
progress, forever intertwined with the evolution of microcontroller
technology.

28
Chapter 1 Microcontroller

Microcontroller: 16 Bit
Within the realm of digital marvels, the microcontroller emerges as a
virtuoso, its capabilities attuned to the intricate dance of commands
and data. Amidst this array of computational artisans, the 16-bit
microcontroller takes its place as a luminary—a beacon of heightened
precision and computational prowess. The heart of this distinction rests
within its ALU—an Algebraic Logic Unit—a domain where mathematics
and logic converge upon a 16-bit stage, orchestrating a symphony of
actions with an expanded palette of bits.
At the core of the 16-bit microcontroller’s elegance lies its intrinsic
alignment with a word’s magnificence—16 bits of data delicately
interwoven, capable of conveying complexities beyond the scope of their
smaller 8-bit counterparts. These microcontrollers embrace their role
with unparalleled finesse, embracing instructions that beckon the ALU
to embark upon a journey across these 16-bit landscapes, unraveling the
nuances of data and command interaction.
This intrinsic synergy extends beyond mere instruction execution,
weaving itself into the very fabric of the microcontroller’s architecture.
Beneath the surface, a digital thoroughfare stretches—its lanes widened to
accommodate the magnificence of 16 bits. This internal bus, 16 bits wide,
parallels the grandeur of the microcontroller’s word length, facilitating the
fluid passage of data across its intricate network.
Venturing into the annals of microcontroller history, exemplars
rise to the fore, etching the essence of 16-bit microcontrollers into the
very framework of digital evolution. The Intel 8096 series, an emblem of
computational sophistication, exemplifies the heights that can be achieved
with a 16-bit architecture. In parallel, the Motorola MC68HC12 and
MC68332 families cast their legacy upon the sands of time, emblematic of
16-bit excellence that reverberates through the ages.

29
Chapter 1 Microcontroller

The distinction between 8-bit and 16-bit microcontrollers


becomes more than just a matter of bit width—it’s a metamorphosis of
computational potential. This transformative shift breathes newfound
life into the realm of control and precision, infusing operations with a
heightened sense of accuracy and performance. The tapestry of 16-bit
microcontrollers weaves a narrative of progression, where bytes expand
into words, and possibilities unfurl with every instruction executed.
It’s in the realm of performance that 16-bit microcontrollers truly
shine, their computational capabilities elevated by their expanded
bit space. The very essence of data manipulation becomes a canvas
for intricate masterpieces, executed with unprecedented finesse. In
comparison to their 8-bit counterparts, 16-bit microcontrollers stand as
beacons of improved accuracy, threading the fine line between efficiency
and detail with remarkable aplomb.
Thus, the 16-bit microcontroller emerges as a testament to digital
evolution—an exemplar of computational advancement that transcends
the boundaries of mere bytes. It is a symphony conductor, orchestrating
mathematical nuances and logical intricacies upon a stage illuminated by
16-bit brilliance. With every bit traversed, every operation executed, the 16-bit
microcontroller inscribes its mark upon the legacy of computational progress,
forever altering the landscape of control, precision, and performance.

Microcontroller: 32 Bit
Within the intricate tapestry of computational ingenuity, a remarkable
archetype emerges—the 32-bit microcontroller—a beacon of
computational might and precision. This titan of digital orchestration
draws its potency from a pivotal source—the Algebraic Logic Unit (ALU)—a
veritable crucible where the magic of 32-bit arithmetic and logical
operations unfurls. In a single instruction, this ALU navigates the expanse of
32 bits, conducting a symphony of calculations with remarkable finesse.

30
Chapter 1 Microcontroller

The defining attribute of the 32-bit microcontroller lies within its very
essence—a 32-bit internal bus width—a digital thoroughfare that mirrors
the grandeur of the ALU’s operations. This widened path stands as a
testament to the microcontroller’s capacity, facilitating the harmonious
flow of data within its circuitry. This internal network becomes the stage
upon which the symphony of computational mastery is enacted—a realm
where bits intermingle, giving rise to nuanced results of unparalleled
complexity.
Embarking upon the annals of microcontroller heritage, certain
luminaries claim their position among the 32-bit elite, etching their
impact upon the continuum of technological advancement. The Intel
80960 family stands as a testament to precision and power, a progenitor
of 32-bit excellence that has shaped the course of computational history.
Meanwhile, the Motorola M683xx and Intel/Atmel 251 families also
grace this pantheon, their very existence a nod to the splendor of 32-bit
architecture.
However, this distinction transcends mere nomenclature—it’s
a metamorphosis of computational might. The leap from 16 bits to
32 bits elevates the microcontroller’s capabilities to unprecedented
heights, facilitating complex operations with remarkable efficiency. The
very architecture of the microcontroller undergoes a transformation,
accommodating the intricacies of 32-bit operations and opening the doors
to a realm where computations occur with breathtaking precision.
In the domain of performance, 32-bit microcontrollers truly
shine, harnessing their expanded bit space to usher in a new era of
computational power. With each instruction executed, the ALU grapples
with a realm of complexity, orchestrating calculations that transcend the
limitations of their predecessors. This heightened computational prowess
propels the microcontroller to new heights, positioning it as a harbinger of
precision, speed, and efficiency.

31
Chapter 1 Microcontroller

In comparison to their 16-bit counterparts, 32-bit microcontrollers


stand as luminous beacons of improved performance. Their architecture
and capabilities resonate with a sense of digital majesty, navigating the
intricate dance of data with unparalleled mastery. They are the virtuosos
of computation, the architects of mathematical marvels, and the standard-­
bearers of a new era in computational excellence.
Thus, the 32-bit microcontroller ascends as a symbol of digital evolution—a
triumph of architectural advancement that reshapes the boundaries of
computation. It wields its 32-bit essence as a tool of empowerment, executing
intricate calculations with precision and speed that elevate the very essence
of control and power. In the grand symphony of technological progress, the
32-bit microcontroller carves its legacy, an indomitable force that has forever
redefined the landscape of computational capabilities.

Embedded Microcontroller
Embedded microcontrollers emerge as the silent architects of seamless
functionality within the intricate tapestry of embedded systems. These
microcontrollers, residing as minuscule chips, harbor within their confines
a symphony of essential functional components—nurturing the very
essence of embedded systems with finesse and precision. At the heart of
their design lies the harmonious interplay of diverse elements, including
program and data memory, weaving a digital fabric that empowers
embedded systems to flourish.
Central to this paradigm is the notion of integration—a concept
that finds its apex within the microcontroller’s architecture. It is the
embodiment of all necessary functional blocks onto a solitary chip that
renders a microcontroller “embedded.” This self-contained entity assumes
the role of a master conductor, orchestrating the nuanced interactions
that define an embedded system’s capabilities. Among these, the
venerable 8051 microcontroller shines as an exemplar—a testament to the
transformative impact of this embedded architecture.

32
Chapter 1 Microcontroller

Within the microcontroller’s heart, the symphony of functionality


converges, setting the stage for an embedded system’s symphony. In
a seamless symphony of digital interplay, program and data memory
interweave, each byte resonating with purpose, each instruction poised to
trigger an elegant cascade of actions. This orchestration finds its crescendo
in the concept of an “embedded microcontroller”—a microcosm of
computational prowess.
Indeed, the embedded microcontroller emerges as a cornerstone
of modern technology—a phoenix that rises from the ashes of isolated
components, bestowing an embedded system with an inherent sense of
unity. In the embrace of integration, the microcontroller’s performance
transcends mere computation, imbued with the potential to galvanize a
vast array of tasks, from automotive control systems to medical devices.
The fusion of microcontroller and embedded system begets a
symbiotic relationship—each enhancing the other’s capabilities. With all
functional blocks harmoniously united on a single chip, the embedded
microcontroller becomes a maestro of digital orchestration, breathing
life into the intricate symphony of an embedded system. The 8051 and its
contemporaries serve as vanguards of this ethos, embodying the fusion of
form and function within the domain of embedded microcontrollers.
In the grand narrative of technological evolution, the embedded
microcontroller emerges as a unifying force—an artisan that shapes the
very fabric of embedded systems. Through its seamless integration, it
bestows upon these systems an aura of efficiency and cohesion. In the
continuum of modern innovation, the embedded microcontroller’s legacy
persists as a testament to the power of integration—an embodiment
of transformation that has forever altered the landscape of embedded
systems design.

33
Chapter 1 Microcontroller

Microcontroller with External Memory


breed of microcontrollers—the “external memory microcontroller.” This
nomenclature encapsulates a microcontroller variant that bears a unique
architectural signature—one that diverges from the conventional norm. In
the symphony of microcontrollers, an “external memory microcontroller”
emerges as a distinct movement—a composition where the functional
blocks, integral to its operation, are dispersed across a broader canvas.
At the very heart of this concept lies a fundamental divergence from
the standard—where the encapsulation of all requisite functional elements
onto a single chip is eschewed. Instead, the functional components that
traditionally find harmony on a solitary chip are disassembled, distributed
across a broader landscape, and connected through a symphony of
interfaces. This architectural intricacy begets a microcontroller that
orchestrates its actions through a dance that involves interplay with
memory units beyond its immediate confines.
In this architectural ballet, the “glue circuit” emerges as a
protagonist—a maestro of interfacing prowess. This circuitry, akin to a
conductor’s baton, bridges the gap between the microcontroller’s internal
landscape and the external memory units that fuel its functionality.
This interfacing marvel navigates the realms of connectivity, ensuring a
seamless dialogue between the external memory microcontroller and the
vast world that envelopes it.
Amidst this intricate interplay, the 8031 microcontroller stands as an
embodiment of the “external memory microcontroller” ethos. Herein, the
absence of on-chip program memory sets the stage for an engagement
with external memory units. This dance of data retrieval and storage
takes on a unique flavor, as the 8031 microcontroller defies convention,
orchestrating its memory operations through a harmonious alliance with
external memory units.
In the broader tableau of microcontroller orchestration, the
“external memory microcontroller” serves as a reminder of architectural

34
Chapter 1 Microcontroller

diversity—a testament that innovation extends beyond the bounds of


tradition. This architectural paradigm transcends the notion of a singular
chip and embraces a broader canvas, where connectivity and interfacing
become the protagonists of the narrative.
In a world where cohesion and integration define microcontroller
design, the “external memory microcontroller” stands as an enigmatic
outlier—a testament to the limitless permutations that architectural
exploration can unearth. The 8031 and its counterparts embody
the symphony of connectivity, external memory engagement, and
architectural divergence, etching their names onto the tapestry of
embedded systems with a unique resonance that echoes through the
corridors of technological evolution.

T he Architectural Specifications
of Microcontroller
Within the intricate tapestry of computational paradigms, the realm of
processors emerges as a pivotal divide—a juncture that delineates the
trajectories of computation. At its core, this division crystallizes into two
luminous archetypes: the Von Neumann, also known as the Princeton
architecture, and the Harvard architecture. These two luminaries, each
with its own constellation of attributes, unfurl a duality that echoes
through the annals of computing history.
The nuances of data and application storage and retrieval become
the touchstones that define this architectural divergence. In the realm
of Von Neumann architecture, a fluid synergy emerges, with data and
applications akin to ephemeral spirits that inhabit a common domain.
Here, the memory reservoir serves as an abode—a repository where both
data and instructions mingle harmoniously. A procession of fetch, decode,
execute, and store unfolds, each step orchestrated within the confines of a
unified memory space.

35
Chapter 1 Microcontroller

Yet, the Harvard architecture dances to a different tune—a melody


of separation that finds resonance in distinction. In this realm, data and
applications exist as discrete entities, each inhabiting their own dedicated
spaces within the memory realm. Here, the memory landscape bifurcates
into separate realms—a stage for data and a canvas for instructions. This
partitioning begets a distinct choreography—a dance where data and
instructions waltz in tandem but without the intimate coexistence of their
Von Neumann counterpart.
The Von Neumann and Harvard architectures are not mere paradigms;
they represent entire ecosystems with implications that ripple through the
realms of computation. The Von Neumann architecture, with its symbiotic
fusion of data and instructions, resonates with a sense of cohesion, where
the memory’s embrace nurtures both elements within its embrace. This
approach, while elegant, does carry the weight of potential bottlenecks—a
consequence of data and instructions vying for the memory’s attention.
In contrast, the Harvard architecture basks in a realm of separation—a
digital realm where clarity reigns supreme. The dedicated memory spaces
for data and instructions yield a streamlined orchestration, unfurling a
computational ballet marked by precision and speed. While it sidesteps
the Von Neumann architecture’s potential bottlenecks, it does introduce
complexities in managing the segregation—a challenge that requires
meticulous choreography.
In the grand narrative of computational history, the tale of these
architectures is etched—a dichotomy that has sculpted the evolution
of processors. They are not just paradigms; they are the architects of
computational landscapes, each shaping the trajectory of computation
in its unique way. In choosing between Von Neumann and Harvard
architectures, designers tread a path marked by implications, trade-offs,
and possibilities—a decision that reverberates through the annals of digital
innovation.

36
Chapter 1 Microcontroller

Thus, the journey through processor architectures transcends mere


technicalities; it is a voyage through the essence of computation itself.
Von Neumann and Harvard architectures stand as a testament to the
myriad ways in which computation can be structured—each a narrative
that weaves its unique spell upon the digital tapestry of technological
evolution.

Von Neumann Architecture


In the intricate fabric of microcontroller architectures, the interplay
of instructions and data unfurls as a symphonic ballet—a dance that
echoes the very essence of computational orchestration. At the heart of
this narrative lies the Von Neumann architecture, an embodiment of this
harmonious interplay, a landscape where instructions and data traverse
the same paths, rendering their synchrony as a hallmark of design.
This architectural dance unfurls with elegance—a melody composed
of shared pathways. In the realm of Von Neumann-based microcontrollers,
the very veins of computation bear witness to the marriage of instructions
and data, as they traverse the same data bus, transcending the boundaries
that often segregate them. Here, data and program instructions coalesce
within a single central memory unit—a symposium of unity where they
dwell as cohabitants within the corridors of a common digital abode.
In the life of a microcontroller under the Von Neumann paradigm,
the controller’s role becomes a journey of two phases—an interplay
of fetches that shape its actions. An instruction’s voyage begins as the
controller fetches the directive, followed by a subsequent retrieval of the
requisite data to support an address in the realm of main memory. This
intricate duet of fetches, while ensuring the unity of data and instructions,
introduces a pacing, a tempo that slows the controller’s cadence as it steps
through its choreography.

37
Chapter 1 Microcontroller

The symphony of the Von Neumann architecture is brought to life


in Figure 1-5—an illustrated testament to the interwoven pathways that
define this microcontroller landscape. Its visual representation is more
than mere lines and shapes; it encapsulates the unity that underscores the
architecture’s design philosophy. This depiction resonates with a narrative
that transcends mere technicality—a narrative that celebrates the harmony
of design.
This unity, intrinsic to the Von Neumann architecture, reverberates
through the realm of microcontroller design, bringing a symphony of
simplification. Through its orchestration, a single memory becomes the
focus of access, streamlining the design process and rendering the intricate
landscape of microcontroller design less complex. This unification extends
to memory usage as well, where Random Access Memory (RAM) emerges
as a vessel for both data and program instructions—a sanctuary where
they coexist, harmonizing their roles within the microcontroller’s realm.
A paragon of the Von Neumann architecture finds its embodiment
in the Motorola 68HC11 microcontroller—a microcosm where these
architectural principles find their expression. Within this realm, an
instruction itself stands as an example—a testament to the architecture’s
functionality. This instruction paints a canvas of action, invoking the
accumulator to reach out to memory, drawing forth a byte to be read and
subsequently enveloped within its digital embrace.
This intricate dance of fetch and execution takes place over cycles, a
rhythmic cadence that defines the microcontroller’s journey. Cycle 1 sets
the stage—a time of familiarization with instructions, a moment where
the microcontroller acquaints itself with the directives that shape its
actions. Cycle 2 brings data from the hallowed halls of RAM, retrieving and
storing it within the accumulator—a microcosm of computation itself, a
testament to the harmonious coexistence of data and instructions within
the symphony of the Von Neumann architecture.

38
Chapter 1 Microcontroller

In this grand narrative of computational ballet, the Von Neumann


architecture assumes a role of prominence—a conductor of unity
where data and instructions merge within the memory’s embrace. This
architecture isn’t just a technical paradigm; it’s a philosophy that shapes
the digital symphony of microcontrollers, orchestrating a dance that
marries the realms of data and instructions in harmonious coexistence.

Figure 1-5. Von Neumann architecture

Harvard Architecture
Harvard architecture, a fundamental concept in computer architecture,
plays a pivotal role in defining how a computer’s processor interacts with
memory and executes instructions. Named after the Harvard Mark I relay-­
based computer from the 1940s, this architecture has evolved over the
years and continues to influence modern computer designs. Let’s delve
into the details of Harvard architecture, its characteristics, advantages, and
applications.

39
Chapter 1 Microcontroller

Basic Principles
Harvard architecture is characterized by its separation of memory for
instructions and data, maintaining distinct pathways for fetching and
processing instructions and data. In this architecture, there are separate
memory units and buses for instruction memory (program memory) and
data memory, ensuring that the processor can simultaneously access both
instruction and data.

Key Characteristics
Separate Memory Spaces: In a Harvard architecture system, instruction
memory and data memory are physically separate. This separation allows
for concurrent access to both instruction and data, improving overall
system efficiency.
Dedicated Buses: Harvard architecture systems employ separate buses
for fetching instructions and reading/writing data. This parallel access
increases throughput and reduces potential bottlenecks.
Instruction Pipelining: The distinct memory paths enable efficient
pipelining, where multiple instructions can be in various stages of
execution simultaneously.
Fixed Instruction Length: Harvard architecture often uses fixed-length
instruction formats, simplifying the decoding process and improving
predictability in instruction fetch and execution.
Performance: The architecture’s parallelism and efficient memory
access contribute to improved performance, making it well-suited for
applications that require high-speed processing.

40
Chapter 1 Microcontroller

Advantages
Faster Throughput: The parallelism offered by Harvard architecture
enables faster execution of instructions, as instructions can be fetched
while data is being processed.
Predictable Timing: The separation of instruction and data memory
simplifies timing analysis, leading to more deterministic execution times.
Reduced Bottlenecks: Dedicated buses for instructions and data
eliminate contention for memory access, reducing potential bottlenecks in
the system.
Higher Performance in Specific Applications: Harvard architecture
is well-suited for applications with heavy instruction access, such as
embedded systems, digital signal processing, and microcontrollers.

Applications
Embedded Systems: Many microcontrollers and digital signal processors
(DSPs) use Harvard architecture due to its efficiency in real-time applications.
Signal Processing: DSPs and multimedia processing units benefit
from Harvard architecture’s ability to simultaneously handle complex
instruction sequences and data manipulation.
Microcontrollers: Low-power microcontrollers often employ Harvard
architecture, optimizing their processing capabilities while minimizing
energy consumption.
Specialized Processors: Harvard architecture is used in specialized
processors for tasks like encryption, graphics processing, and network
packet handling.
In modern implementations, some architectures use a modified
Harvard architecture, where aspects of Von Neumann architecture
(a unified memory for data and instructions) are integrated with the
Harvard approach. This modification can balance the advantages of both
architectures to suit specific requirements.

41
Chapter 1 Microcontroller

In conclusion, Harvard architecture’s separation of instruction and


data memory, along with its dedicated buses, offers advantages in terms of
performance, throughput, and predictability. Its influence can be seen across
a wide range of applications, from microcontrollers to specialized processors,
where efficient instruction execution and data processing are essential.

Figure 1-6. Block diagram of Harvard architecture

 ISC (Complex Instruction Set Computer)


C
Architecture for Microcontroller
Within the intricate architecture of modern microcontrollers, an
overarching paradigm emerges—an archetype that guides their design,
dictates their orchestration, and shapes the very essence of their
computational choreography. This paradigm, known as CISC—Complex
Instruction Set Computer—finds its embrace within the vast majority of
contemporary microcontrollers, a testament to its pervasive influence
within the digital realm.

42
Chapter 1 Microcontroller

At its heart, the CISC architecture isn’t just a design philosophy;


it’s a symphony of instructions, a symposium where the orchestra of
computational actions takes center stage. This architecture paints a
landscape where instructions find their distinct roles, a tapestry woven
with multiple addressing modes for a multitude of operations. Be it
arithmetic and logical operations, data transfer, or memory access,
the CISC architecture weaves a digital melody that resonates with the
complexity of computation.
One hallmark of the CISC architecture is the rich palette of instructions
it offers—a bounty that extends to over 80 distinct directives. Within this
vibrant spectrum lies a diversity of commands, each tailored to a specific
facet of computation. Some are versatile, their purpose spanning a broad
swath of applications. Others, however, are artisans of specialization—
precision instruments designed to perform intricate control tasks with
finesse.
The realm of CISC microcontrollers isn’t a monolith; it’s a realm of
nuances, where instructions respond to a symphony of stimuli in a diverse
manner. Specific address spaces and registers find allegiance within
certain instructions, while distinct addressing modes find recognition
within others. This mosaic of recognition and allegiance weaves a
landscape of complexity, where each instruction reacts to its environment
with distinct behavior, orchestrating the dance of computation with
precision.
An intriguing facet of the CISC architecture is its propensity for macro-­
like instructions—a realm where complexity conceals elegance. Here,
instructions assume the guise of macros, offering a singular command
that encapsulates the actions of multiple simpler ones. This macro-like
behavior doesn’t just simplify programming; it elevates the very essence of
instruction design, offering a window into the synthesis of complexity and
simplicity.

43
Chapter 1 Microcontroller

In the pantheon of CISC microcontrollers, a luminary emerges—the


Intel 8096 series. This microcontroller stands as a testament to the CISC
design ethos—a realm where complexity meets artistry. Within the Intel
8096 series, the symphony of CISC architecture unfurls, orchestrating the
journey of computation with elegance and precision.
In the grand narrative of microcontroller evolution, the CISC architecture
assumes the role of a guiding star—a compass that directs the trajectory of
design and implementation. It’s more than an architecture; it’s a philosophy
that paints a landscape where complexity is embraced, where instructions
dance in harmony with data, where a tapestry of precision and specialization is
woven within the digital realm. Through the embodiment of microcontrollers
like the Intel 8096 series, the legacy of CISC architecture shines—a testament to
the symphony of complexity that underlies the world of modern computation.
Complex Instruction Set Computer (CISC) architecture is a prominent
design approach used in microcontrollers and processors, aiming to
provide a wide array of powerful and versatile instructions within a single
instruction set. CISC architectures contrast with Reduced Instruction Set
Computer (RISC) architectures, which prioritize simplicity and efficiency
by using a smaller set of basic instructions.

Key Characteristics and Features


Multifunction Instructions: CISC architectures offer instructions that can
perform complex operations in a single instruction. These instructions
can involve memory access, arithmetic operations, logical operations, and
control flow manipulation, reducing the number of instructions needed to
accomplish a task.
Memory Access Modes: CISC architectures often support various
addressing modes, allowing instructions to access memory in diverse
ways, such as direct addressing, indirect addressing, and indexed
addressing. This flexibility simplifies programming but may also result in
more complex hardware.

44
Chapter 1 Microcontroller

Hardware Emphasis: CISC architectures put a significant load on


hardware components to decode and execute complex instructions. This
approach aims to shift the complexity from software to hardware, making
the microcontroller more capable of performing intricate tasks.
Rich Instruction Set: CISC architectures can have hundreds of
instructions, including specialized instructions tailored for specific
operations. This rich instruction set enables developers to write compact
and feature-rich code.
Variable-Length Instructions: Instructions in CISC architectures can
have varying lengths, with some instructions requiring more memory than
others. This adaptability allows the architecture to accommodate different
levels of complexity.
Microcoding: In CISC architectures, complex instructions are often
implemented using microcode. Microcode is a sequence of simpler
instructions that the microcontroller executes to perform the desired
complex operation.

 dvantages of CISC Architecture


A
for Microcontrollers
Higher-Level Abstractions: The rich instruction set and complex
instructions of CISC architectures enable developers to write more concise
and expressive code, translating high-level abstractions directly into
instructions.
Reduced Memory Footprint: With complex instructions, fewer
instructions are required to perform a task, leading to a smaller memory
footprint for programs.
Optimized for Code Density: CISC architectures excel at optimizing
code density, enabling the execution of a wide range of operations with
fewer instructions.

45
Chapter 1 Microcontroller

Ease of Programming: CISC architectures simplify programming by


providing instructions that combine multiple operations. This can save
time and effort in software development.
Efficient for Certain Applications: CISC architectures are well-suited
for applications that require a mix of general-purpose and specialized
operations, such as signal processing, control systems, and data
manipulation.

Challenges and Considerations


Complexity: The complexity of the instruction set and hardware required
to execute complex instructions can lead to more intricate and harder-to-­
predict behavior.
Power Consumption: The increased hardware complexity of CISC
architectures can result in higher power consumption compared to
simpler architectures like RISC.
Instruction Decoding Overhead: The decoding of complex instructions
can introduce overhead and potentially slow down the instruction fetch
and execution process.
Limited Parallelism: The complexity of instructions can make it
challenging to execute multiple instructions in parallel, limiting the
potential for instruction-level parallelism.
Design and Verification Complexity: Developing microcontrollers
based on CISC architectures demands thorough design and verification
efforts due to the intricacies of instruction execution and the potential for
corner cases.
In conclusion, CISC architecture for microcontrollers offers a trade-­
off between hardware complexity and software efficiency. It provides a
diverse set of instructions to cater to various application requirements
and allows developers to write more concise code. However, it also
comes with challenges related to complexity, power consumption,
and potential performance trade-offs. CISC architectures continue

46
Chapter 1 Microcontroller

to be relevant in microcontroller design, especially for applications


where the advantages of a rich instruction set outweigh the associated
complexities.

 ISC (Reduced Instruction Set Computer)


R
Architecture for Microcontroller
• Amidst the ever-evolving landscape of microprocessor
design, a tide of innovation ushers forth—a shift that
navigates the currents of progress toward new horizons.
Within this dynamic realm, the RISC (Reduced
Instruction Set Computer) architecture stands as a
guiding beacon—a paradigm that draws designers
and engineers toward a new era of computational
orchestration.

• In the world of microcontroller design, the transition


to RISC architecture signals a reimagining of the
very essence of computation. This transformation
culminates in the birth of RISC microcontrollers—
digital entities defined by a discerning characteristic:
a curated instruction set that boasts a limited array
of address modes, meticulously chosen to support
an array of arithmetic, logical, and data transfer
operations.

• The allure of RISC architecture rests in its simplicity—a


simplicity that yields profound implications. This
design ethos, characterized by reduced complexity,
begets a cascade of benefits. A RISC microcontroller
wears its simplicity as a badge of honor—a badge
that translates into tangible results: a smaller chip

47
Chapter 1 Microcontroller

footprint, a reduction in the number of pins required,


and a commendably low power consumption. In this
symphony of design, the harmony of simplicity and
efficiency resonates.

• Delving deeper into the tapestry of RISC architecture,


we encounter the Harvard architecture—a realm that
embodies distinct traits that distinguish it from the norm.
One hallmark of this architecture is the unique synergy it
fosters—a realm where program and data harmoniously
coexist, accessed simultaneously. This concurrent access
isn’t just an architectural feat; it’s a testament to the RISC
processor’s ability to transcend traditional constraints,
ushering in a symphony of streamlined processing.

• Within the realm of the Harvard architecture, an


artful overlaying of activities unfolds—a process
where various activities are interwoven to hasten the
pace of processing. This orchestration is more than
just optimization; it’s a dynamic choreography that
demonstrates the versatility and adaptability of the
RISC architecture, transcending limitations to unlock
new realms of efficiency.

• Execution speed receives a turbocharged boost through


the orchestration of instruction pipelining—an intricate
dance of computation where the stages of instruction
execution overlap, propelling the microcontroller
into a realm of accelerated processing. This ballet
of instructions unfolds seamlessly, epitomizing the
synergy that resides within the microcontroller’s
architecture, transforming ordinary actions into a
symphony of speed and efficiency.

48
Chapter 1 Microcontroller

• In the realm of RISC architecture, a symmetrical—or


orthogonal—set of instructions prevails, a design
philosophy that bestows the gift of simplicity upon
programmers. This symmetrical design doesn’t just
streamline programming; it becomes a conduit for
creativity, empowering programmers to wield a diverse
array of instructions with an elegance that defies
complexity. In this symphony of instruction, RISC
microcontrollers paint a canvas where programming
becomes an art of precision and creativity.

• Further exemplifying the ethos of versatility within


the RISC architecture, the realm of addressing modes
and registers unfurls with a unique proposition—a
proposition that endows any instruction with the
liberty to choose any register or addressing mode. This
democracy of versatility shatters boundaries, offering
programmers a palette of choices that transcends the
traditional confines of instruction usage.

• In the grand tapestry of microcontroller evolution, RISC


architecture assumes its rightful place—a paradigm
that crafts a symphony of efficiency and elegance.
Through the embodiment of RISC microcontrollers,
the industry steers toward a new dawn, embracing
simplicity and versatility as guiding stars. As we
traverse this landscape of innovation, the legacy of
RISC architecture unfurls—a legacy that sings the song
of streamlined efficiency, harmonious coexistence, and
the artful ballet of computation.

49
Chapter 1 Microcontroller

 ISC (Specific Instruction Set Computer)


S
Architecture for Microcontroller
Amidst the labyrinthine corridors of computational concepts, a pivotal
notion takes center stage—an entity known as RISC, an acronym that
embodies a transformative paradigm. At its core, a RISC (Reduced
Instruction Set Computer) isn’t merely an architectural design; it’s a
microcontroller in its very essence—a marriage of design principles that
culminate in a symphony of computational elegance.
However, an alternative perspective emerges—one that challenges
nomenclature and invites contemplation. A thought springs forth,
suggesting that perhaps a more apt appellation for this entity might be a
SISC (Specific Instruction Set Computer). This notion, while a departure
from convention, encapsulates a nuanced essence—a recognition that
the heart of this machine lies in its specificity, its tailored instructions that
resonate with a purposeful orchestration.
The birth of the microcontroller, at its core, carries a singular
mission—to restrain the ambitions of the CPU, curbing its capacities to
accommodate an entire digital realm within the confines of a solitary
chip. This orchestration isn’t just an exercise in efficiency; it’s an act of
architectural brilliance—a harmonious convergence of memory, I/O
operations, and interrupts within the boundaries of a single chip.
Yet, in this symphony of design, a choice is made—a sacrifice
is tendered at the altar of versatility. The allure of general-purpose
instructions, the very essence that lends simplicity to renowned
microprocessors like the 8088, 68000, and 32032, is traded for a different
tune. Instead, a symphony of instructions emerges, tuned to the rhythm of
control, an arrangement that brings forth a microcontroller designed for
precision in steering specific tasks.

50
Chapter 1 Microcontroller

In the grand tapestry of computational evolution, this dance of design


principles and purpose yields the microcontroller—a harmonious blend
of specificity and restraint. It’s more than a mere machine; it’s a testament
to the synergy of intent and design, a nod to the precision that underscores
the world of microcontrollers.
As we gaze upon the realm of RISC, this convergence of specificity
and architectural ingenuity resonates—a legacy that beckons to a world of
purposeful orchestration. Through the lens of SISC, the microcontroller
steps forth as a torchbearer—a sentinel that encapsulates the heart
of specific instruction, transforming it into a symphony of control, a
choreography of precision.

Applications of Microcontrollers
In the intricate web of embedded systems, a quintessential element takes
center stage—the microcontroller, a digital maestro that orchestrates a
symphony of functions within these intricate constructs. Within this realm,
a microcontroller isn’t merely a cog in the wheel; it’s the driving force that
empowers home monitoring systems, breathing life into their functionality
and ensuring seamless operation.
Beyond its foundational role in home monitoring, the realm of
microcontrollers extends its grasp across a multitude of domains, each
a canvas for its versatile capabilities. From the automotive sector to
the domain of household appliances—microwave ovens, refrigerators,
televisions, and VCRs—the microcontroller dons myriad roles, weaving a
tapestry of precision and automation. The automobile landscape witnesses
the microcontroller’s prowess in engine control and climate diagnostics,
while the factory floor becomes an arena where microcontrollers orchestrate
operations with finesse. From the realms of instrumentation to the expanse
of aerospace, the microcontroller’s touch is felt—an indelible mark that
transforms ordinary devices into instruments of efficiency and precision.

51
Chapter 1 Microcontroller

In the dance of functionality, robotics emerges as a realm where


microcontrollers hold sway—an orchestra of automation where
countless microcontrollers collaborate to execute an array of tasks. In
this symphony of mechanical movement, communication takes center
stage as microcontrollers converse with one another, linked by a central
microcontroller or even a colossal computer. This dialogue isn’t mere
chatter; it’s a choreography that enables processing, information exchange,
and collaboration within the system—a testament to the microcontroller’s
role in the realm of robotics.
In the world of data, microcontrollers emerge as virtuosos—adept
at the art of logging and capturing environmental nuances. Data logging
becomes their forte, a domain where they excel with remarkable finesse.
Placed within diverse environments, from corn fields to floating balloons,
these chips become sentinels of information, recording environmental
factors with precision—temperature, humidity, rain, and more. Their
compact size, frugal power consumption, and adaptability render them
ideal companions for unattended data monitoring—a testament to their
versatility in capturing and recording data.
In the grand narrative of digital evolution, the microcontroller emerges
as a linchpin—a nexus where technology and functionality converge.
Beyond its role as a component, it becomes a beacon of automation, a
facilitator of precision, and a harbinger of innovation. Within embedded
systems and beyond, the microcontroller weaves its magic—a testament to
the harmony between engineering and imagination.
Microcontrollers find applications in a wide range of fields and
industries due to their compact size, low power consumption, and ability
to control and interact with various systems. They serve as the “brains” of
many devices, enabling automation, control, and intelligence. Here are
some key applications of microcontrollers:

52
Chapter 1 Microcontroller

1. Embedded Systems: Microcontrollers are the


heart of embedded systems, powering devices like
washing machines, microwave ovens, thermostats,
and digital cameras. They handle tasks such as
sensing inputs, processing data, and controlling
outputs, making these devices smarter and more
efficient.

2. Consumer Electronics: Microcontrollers


drive various consumer electronics, including
smartphones, tablets, smart TVs, and wearable
devices. They manage user interfaces, touchscreens,
wireless communication, and power management.

3. Automotive Systems: Microcontrollers are essential


in modern automobiles for engine control, anti-
lock braking systems (ABS), airbag deployment,
infotainment systems, navigation, and advanced
driver assistance systems (ADAS) like adaptive
cruise control and lane departure warning.

4. Industrial Automation: Microcontrollers play a


crucial role in industrial automation, controlling
processes in factories, robotics, assembly lines, and
manufacturing equipment. They enable real-time
monitoring, data collection, and precise control over
machinery.

5. Internet of Things (IoT): IoT devices rely on


microcontrollers to connect to the Internet
and exchange data. From smart thermostats to
wearable fitness trackers, microcontrollers facilitate
communication and data processing, enabling
remote control and monitoring.

53
Chapter 1 Microcontroller

6. Medical Devices: Microcontrollers are used in


medical equipment such as heart rate monitors,
insulin pumps, blood glucose meters, and medical
imaging devices. They enable accurate data
collection, analysis, and treatment delivery.

7. Home Automation: Microcontrollers power smart


home devices like smart locks, lighting systems,
security cameras, and voice-controlled assistants.
They allow users to control and monitor their homes
remotely.

8. Renewable Energy Systems: Microcontrollers are


integrated into solar inverters, wind turbines, and
energy management systems to optimize energy
production, monitor system performance, and
ensure efficient energy utilization.

9. Communication Systems: Microcontrollers


enable wireless communication in devices such
as Bluetooth headphones, wireless speakers, and
remote controls. They process and transmit data
over radio frequencies.
10. Entertainment and Gaming: Microcontrollers drive
gaming consoles, handheld gaming devices, and
arcade machines. They handle graphics, sound, user
input, and game logic.

11. Aerospace and Defense: Microcontrollers are used


in aerospace applications for flight control, avionics,
satellite communication, and navigation systems.
In defense, they play a role in radar systems, drones,
and secure communication.

54
Chapter 1 Microcontroller

12. Educational Tools: Microcontrollers like Arduino


and Raspberry Pi are popular platforms for teaching
electronics, programming, and engineering
concepts. They provide hands-on experience in
building projects and prototypes.

13. Agriculture: Microcontrollers find use in precision


agriculture for monitoring soil conditions, irrigation,
weather data, and crop health. They help optimize
resource usage and enhance crop yield.

14. Biometrics and Security: Microcontrollers are


used in biometric authentication devices such as
fingerprint scanners, retinal scanners, and facial
recognition systems. They ensure secure access and
identity verification.

15. Environmental Monitoring: Microcontrollers are


employed in environmental monitoring systems to
track air quality, water quality, weather conditions,
and pollution levels.

The versatility and adaptability of microcontrollers make them


essential components in countless applications across industries, driving
innovation, efficiency, and convenience in our daily lives. As technology
continues to advance, microcontrollers will likely play an even more
significant role in shaping the future of various fields.

55
CHAPTER 2

Basics
Embarking on a comprehensive journey to explore the intricacies of circuit
simulation, we will navigate step by step through the process using the
versatile platform of Tinkercad. Through this detailed guide, you will gain
a profound understanding of initiating the simulation process and delving
into the immersive world of virtual circuits.
Begin by accessing the digital realm of Tinkercad via your web browser.
As the official Tinkercad website, tinkercad.com, loads before you, you’ll
find an array of possibilities awaiting your exploration. To unlock the full
potential of Tinkercad’s circuit simulation capabilities, click the “Sign In”
option, which serves as your gateway to a realm of digital creativity and
hands-on learning.
With your eagerness to delve into circuit simulation, you’ll be
prompted to provide your credentials. Input your registered email address
and the corresponding password associated with your Tinkercad account.
This personalized key grants you access to a world of innovation where you
can engage in immersive circuit simulations.
Upon signing in, the interface of Tinkercad greets you, presenting
an array of options on the left side of the screen. This interface serves as
the launchpad for your circuit simulation journey. Among these options,
find and click “Circuits,” the guiding star that beckons you to explore the
intricate world of circuitry. This is your starting point, your compass to
navigate through the intricacies of circuit simulations.

© Ashraf Said Ahmad AlMadhoun 2023 57


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_2
Chapter 2 Basics

As you select “Circuits,” a new vista unfolds—an entire section


dedicated to the exploration of circuitry. This section is a realm where
ideas come to life, circuits are conceptualized, and theoretical knowledge
transforms into practical understanding. It’s here that you’ll embark on
your journey of learning and exploration.
Within the “Circuits” section, a pivotal option stands before you—
labeled “Try Circuits.” By selecting this option, you unlock an immersive
experience that bridges theory and practice. This interactive platform
allows you to simulate circuits, experiment with components, and observe
how they behave in different scenarios. As you click “Try Circuits,” the door
to the world of simulated circuits swings open before you.
Upon entering the simulation environment, a digital canvas
unveils itself—a canvas populated with circuit components, wires, and
connections. This is where concepts take shape, where you witness the
manifestation of theoretical ideas in a virtual form. Amidst this digital
landscape, you’ll likely encounter a specific circuit configuration depicted
in Figure 2-2. This visual representation serves as a reference point,
offering insights into the concepts you’re about to explore.

Figure 2-1. Tinkercad and Circuits option

58
Chapter 2 Basics

Figure 2-2. Tinkercad circuit

As you traverse this simulated circuit landscape, you’re encouraged to


interact with the components, initiate changes, and observe their effects.
This interactive playground encourages experimentation, providing a safe
and dynamic environment to learn through hands-on exploration.
Embarking on the journey of electronic circuit simulation within
this application, we will delve into the process step by step, unlocking
the power to visualize and comprehend electronic phenomena. As you
immerse yourself in this exploration, you’ll encounter an initial circuit
scenario—a configuration featuring an LED connected to a battery.
Through the upcoming instructions, you’ll learn how to initiate the
simulator and observe circuit behavior in real-time.
The first step is to observe the circuit configuration before you—a
simple yet foundational setup involving an LED and a battery. To initiate
the simulation, you’ll need to access a vital control—the “Start Simulation”
button—positioned conveniently at the top right corner of the screen,
highlighted in an inviting shade of green.

59
Chapter 2 Basics

As your cursor hovers over this button, its significance becomes


clear—it serves as the catalyst that ignites the simulation process. With a
click on the “Start Simulation” button, you unleash a cascade of virtual
electrons, initiating the flow of current within the circuit. In this moment,
the LED springs to life, emanating its characteristic glow, a testament to
the successful commencement of the simulation.
As your exploration deepens, you’ll find yourself drawn to the LED,
an electronic sentinel that holds a story within its illumination. Upon
hovering your cursor over the LED, a note materializes, offering a glimpse
into the circuit’s behavior. The note, depicted in Figure 2-3, presents a
vital piece of information—the current coursing through the LED. At this
juncture, you discover that the LED’s current reads 61.9 milliamperes, a
numeric insight into the circuit’s dynamics.
However, the information doesn’t stop there. The note also imparts
another nugget of knowledge—the recommended maximum current for
the LED, pegged at 20 milliamperes. This revelation offers a safeguard
against pushing the LED beyond its optimal performance range.
This digital ecosystem doesn’t merely simulate a circuit—it educates,
elucidates, and empowers. It’s a realm where insight blossoms from every
simulated electron, where understanding flows in tandem with current.
And thus, your first circuit simulation unfolds—a harmonious dance
of electrons, a symphony of data, and a tapestry of insights. As you’ve
witnessed, this website is a treasure trove of information, a digital haven
that provides a lens into the electronic realm.
What you’ve accomplished is a testament to your initiation into circuit
simulation. You’ve unlocked the capability to not only visualize but also
experiment with circuit designs in a controlled virtual environment. This
simulator empowers you to refine your ideas, test your theories, and delve
into the intricacies of electronic behavior—transforming your journey into
a blend of theory and practice.

60
Chapter 2 Basics

Figure 2-3. Information about LED

Check out the starter circuits which you can find by clicking the Basics
options given on top right corner shown on Figure 2-4.

Figure 2-4. Basic circuits in Tinkercad

Navigating the realm of electronic design using the EAGLE software,


we now turn our attention to a pivotal aspect—exporting your carefully
crafted circuit design in the EAGLE.BRD format. Through this process,
you’ll gain the power to preserve your ingenuity and share your creation
with the world. Let’s delve into the steps that empower you to take your
design beyond the digital canvas.

61
Chapter 2 Basics

Exporting Design in EAGLE.BRD Format


Embarking on Export: With your circuit design honed to perfection, your
next move is to give it a tangible presence in the real world. Locate the
“Export” button within the interface—a beacon signaling the transition
from digital to tangible.
The Art of Sharing: Alongside the Export button, a companion
emerges—the “Share” button. This digital envoy enables you to share
your circuit design with others, fostering collaboration and knowledge
exchange. Additionally, it offers the option to download a snapshot of your
circuit, capturing a moment frozen in the electronic continuum.

Exploring Component Manuals


A Path to Understanding: Amidst your design journey, you’ll encounter
the need to delve deeper into the specifics of components—the building
blocks of your circuit. To cater to this need, an option resides on the
right side of the interface, extending an invitation to unveil component
manuals. This informational portal, as depicted in Figure 2-5, grants you
access to a treasure trove of insights.

62
Chapter 2 Basics

Figure 2-5. Component manual

As you engage with the Export and Share buttons, you open gateways to
extend the reach of your design. Exporting in the EAGLE.BRD format lays
the groundwork for physical realization, inviting the transformation of bits
and bytes into tangible circuitry. The Share button, on the other hand, is the
conduit for collaboration, facilitating the exchange of ideas and expertise.
And there’s more—a feature that illuminates your path toward
mastery. On the right side of the interface, a discreet yet invaluable
option beckons you—a gateway to component manuals. This gateway
provides a roadmap to understanding the intricacies of each component’s
functionality, specifications, and optimal usage.
With these features at your fingertips, you navigate the intricate
landscape of electronic design with finesse. As you stand at the crossroads
of exportation, sharing, and in-depth understanding, you wield the tools to
shape the course of your circuit design journey. Every click, every choice,
and every exploration propels you closer to mastery, transforming the
digital into the tangible and expanding the horizons of your electronic
creations.

63
Chapter 2 Basics

You can click the Basic on Starter menu to simulate some other
premade basic circuits as we have shown in Figure 2-4. You can also
explore other options given in that menu, for example, Arduino, to
simulate Arduino-based circuits. Let’s explore the last option in that menu,
named All. Click the LED dimmer circuit. It consists of an LED and a
potentiometer to control the brightness of the LED.
Now we have a menu on the left top, as you can see in Figure 2-6 with
a red rectangle. The first option is used to Rotate component, then we
have an option to delete the components, and the next options are for
undo and redo. You can also keep some notes by using the Noes option on
this menu.
On the left side, we have a quick guide that you can use to make sure
that you are doing things right. This is mentioned with a blue rectangle in
Figure 2-6.
The zoom in and out option is given on top left corner and is shown
with a green circle on Figure 2-6.

Figure 2-6. Menu, Quick Guide, and Zoom in and out options

64
Chapter 2 Basics

You can also see and download the component list using the
Component List option on the top right menu which is shown in
Figure 2-7.

Figure 2-7. Component List option

Generating a Shareable CSV File


Download and Share: With your circuit design aligned and components
meticulously placed, the time has come to immortalize your efforts in a
shareable format. This is achieved through the art of generating a CSV
(Comma-Separated Values) file—a digital vessel that encapsulates your
design’s essence.

65
Chapter 2 Basics

Component Details Unveiled: As you delve into the CSV format, the
details of your circuit components are poised to take center stage. This
file eloquently showcases the names of each component, accompanied
by their respective quantities and values. This structured arrangement
ensures that your design’s building blocks are comprehensively
conveyed.
Visualizing the Component List: For clarity and insight, visualize
the culmination of your design’s components through the prism of a
comprehensive list. This list—akin to a map of your circuit’s landscape—
is exemplified in Figure 2-8. It serves as both a reference point and a
testament to the meticulous organization of your design.

Interacting with the CSV File


A World of Possibilities with Excel: Armed with your CSV file, you have
the key to a world of data manipulation and analysis. By employing a tool
as versatile as Microsoft Excel, you can seamlessly open the CSV file and
explore its contents.
Navigating the Content: As the CSV file unfolds within Excel’s
interface, you’ll observe the individual components, their quantities, and
their corresponding values neatly arranged in columns. This organized
presentation empowers you to grasp the holistic picture of your design’s
composition.
Data Manipulation: Excel’s capabilities extend beyond mere
visualization. You can manipulate and analyze the data within the CSV file,
applying formulas, generating graphs, and deriving insights that amplify
your understanding of the circuit’s nuances.

66
Chapter 2 Basics

Figure 2-8. Component List

67
CHAPTER 3

Explaining the
Interface
and Simulating
Your First Circuit
Continuing our exploration of the dynamic landscape of Tinkercad, we
embark on a new chapter—an odyssey of enhanced understanding and
mastery. Building upon the foundation laid in the previous chapter, where
we delved into the process of setting up your account and acquainting you
with the platform’s basic interface, we now transition into a deeper realm
of exploration.

Unveiling the Intricacies


The Prelude to Depth: As the curtain rises on this chapter, we take a
moment to revisit the setting of the stage. In the preceding chapter, you
journeyed through the steps of establishing your Tinkercad account—a
key to unlocking a realm of digital innovation. Additionally, you were
introduced to the basic interface, familiarizing yourself with the tools at
your disposal.

© Ashraf Said Ahmad AlMadhoun 2023 69


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_3
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Diving into Details: With this chapter, the canvas expands, inviting you
to dive deeper into the intricacies of Tinkercad. Here, we navigate beyond
the surface, peeling back the layers to reveal the comprehensive toolkit
that empowers your creative endeavors.

Editing Components and Parameters


A Symphony of Components: Central to your exploration is the art of
component editing—a skill that allows you to sculpt and refine your
circuit’s building blocks. As you journey through this chapter, you’ll
traverse the landscape of different components, manipulating their
attributes to align with your design vision.
Parameters Unveiled: In your quest for mastery, parameters become
your allies. Here, you unravel the significance of each parameter, gaining
insight into how they shape the behavior and functionality of components.
This knowledge fuels your ability to craft designs that align with
your intent.
The Edit Canvas: Your journey into component editing is an immersive
experience. You’ll interact with an edit canvas—a virtual realm where
your creativity takes tangible form. Here, you’ll fine-tune attributes,
adjust parameters, and breathe life into your design through nuanced
modifications.
In essence, this chapter is your portal to deeper mastery within the
Tinkercad universe. Through comprehensive exploration, you transcend
the basics, navigating through the intricate dimensions that define your
creative prowess. As you delve into the art of component editing and
parameter manipulation, you ascend from a novice to an adept, equipped
with the skills to shape and refine your designs with finesse. This chapter,
a chapter of transformation and insight, empowers you to embrace the
complexity of circuit design, nurturing your journey toward expertise and
innovation.

70
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Editing Components
You can start by opening one of the starter kits as shown in Figure 3-1.

Figure 3-1. Information about LED

We will opt the Blink circuit having one red LED in it. Let us place a
resistor in series from the basic components, and the final circuit should
look like the one in Figure 3-2.

Figure 3-2. Information about LED

Turning our attention to the visual landscape before us, we find


ourselves immersed in a circuit—a mosaic of electronic elements that
beckon our exploration. At this juncture, we encounter a resistor nestled
within this digital terrain—an enigmatic presence whose purpose will be
unveiled in due time. For now, our focus is on a foundational lesson—a
lesson that unveils the components within your workspace.

71
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Observing the Circuit’s Ensemble


The Resistor’s Prelude: As you gaze upon the circuit’s canvas, your
attention may be drawn to the resistor, a seemingly unassuming element
that holds a secret purpose. While this purpose remains shrouded for the
moment, its significance will gradually unfold as you delve deeper into
your learning journey.
A Survey of Components: As we embark on this lesson, your primary
task is to acquaint yourself with the ensemble of components within your
workspace. These elements, each bearing unique attributes, are essential
building blocks in your electronic endeavors. Ensuring that your gaze
encompasses all these components sets the stage for your next step.

Crafting a Traffic Light Application


Embarking on Application: The journey takes a compelling turn as we
embark on the creation of a traffic light system—an application that marries
theory with practicality. In this endeavor, two additional LEDs will step onto
the stage, each playing a role in illuminating the path of understanding.
Components from the Arsenal: To bring this application to life, you
have a choice—to select these additional LEDs from the basic elements
library or seamlessly duplicate existing ones. This choice empowers you
to craft your design with flexibility and precision, aligning your vision with
the components at hand.
Enter the Resistor: As your application takes shape, the resistor takes
its rightful place within the circuit—a critical component that contributes
to the functionality of the traffic light system. Your circuit, evolving with
purpose, mirrors the configuration depicted in Figure 3-3—a testament to
your progress.

72
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Figure 3-3. Information about LED

Establishing Connections
Linking to the Arduino: An essential bridge in your circuit is the
connection to the Arduino board. As you weave the threads of
connectivity, channel your focus toward the top hole numbers—0, 1,
and 2. These entry points hold the key to orchestrating the dance of
electronic signals, giving life to your circuit’s behavior.
Completing the Circuit: In the realm of electronic symbiosis,
grounding is paramount. Ensure that the trio of LEDs maintains its
connection to the ground, completing the circuit’s loop. Through this
bond, the LEDs find their grounding, anchoring your circuit’s operation.

The Unveiling of the Inspector


A Portal to Customization: With a simple click, the Inspector emerges—a
virtual portal that grants you control over the intricate nuances of your
chosen LED component. Here, a plethora of properties come to light, each
ready to be molded according to your design aspirations.

73
Chapter 3 Explaining the Interface and Simulating Your First Circuit

The Realm of Customization: Within the Inspector’s confines, the


canvas of customization unfurls. Properties dance before your eyes—each
representing a facet of your component’s identity. From name to color,
each property is a brushstroke in the canvas of your circuit’s aesthetics.

Bringing Realism to Your Application


Chasing Realism: Your application’s evolution transcends the realm of
functionality. As you aim to infuse realism, a key step beckons—altering
the color of wires that tether to the grounding, weaving an immersive
narrative. The transformation of these wires to black hues marks a
conscious stride toward harmonizing aesthetics with function.
A Spectrum of LED Colors: In the pursuit of a more authentic traffic
light experience, the LEDs become your canvas of expression. The simple
act of color alteration transports these components into the realms of red,
yellow, and green—a visual symphony that echoes the familiar language of
traffic signals.

Configuring Resistance Properties


Resistance in Focus: Amidst the symphony of components, the resistor
emerges as a pivotal contributor to the circuit’s behavior. With a value of
220 ohms, the resistor becomes a cornerstone in the design’s electrical
architecture. And while the possibility for value adjustment exists, for the
sake of your current journey, the resonance of 220 ohms will resonate
harmoniously.
Culmination in Circuit Design: As you sculpt, alter, and refine your
components through the Inspector’s gaze, the culmination of your efforts
materializes. Your circuit, now intricately adorned with the personalized
attributes you’ve bestowed upon each element, takes on the form
illustrated in Figure 3-4—a vision transformed into reality.

74
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Figure 3-4. Information about LED

In this phase of your circuit journey, the Inspector becomes your


compass—guiding you through the landscapes of customization. Each
property tweak, each alteration, is a brushstroke that shapes your design’s
identity. As wires turn to black, LEDs radiate traffic hues, and resistors bear
ohmic values, your circuit transcends functionality to embrace a realm
where aesthetics and technical precision interlace. It is here that your
circuit’s transformation from abstraction to tangible creation finds its vivid
expression.
If we talk about the programming style, the Tinkercad allows you to
code in blocks and in text. Click the option of code as shown in Figure 3-5.

Figure 3-5. Information about LED

75
Chapter 3 Explaining the Interface and Simulating Your First Circuit

As you stand at the precipice of coding completion, your journey takes


a pivotal turn—one that leads you toward the realm of experimentation
and validation. A single click, a simple action, propels you into a world
of testing and refinement—a realm where your traffic light circuit comes
alive, pulsating with the energy of your coding efforts.

Embarking on the Simulation Journey


The Moment of Activation: With your code meticulously assembled, you
stand poised to breathe life into your circuit’s behavior. Your gateway to
this transformative experience lies in the unassuming “start simulation”
button—the beacon of initiation that resides in the top right corner. A
simple click sets in motion a sequence of events that encapsulates the
essence of your coding endeavors.
Venturing into the Simulation: As you heed the call of simulation,
your circuit transcends the confines of imagination and ventures into
the realm of reality—or rather, virtual reality. Here, the lights dance in
sync, embodying the logic you’ve woven into the code. It’s a moment of
validation, where the harmonious coordination of components manifests.

The Art of Tinkering


Exploring the Playgrounds: In this digital playground, the canvas is yours
to tinker with. You’re not confined to a single narrative; instead, the space
beckons exploration. The canvas is painted with components—each a
thread in the intricate tapestry of your circuit. Dare to experiment; dare to
select different components and observe their impact.
Unveiling the Component’s Potential: With a curious spirit as your
guide, select different components within the design and discover their
inherent potentials. Each element, a piece of the puzzle, holds secrets
that unravel as you delve deeper. Experimentation becomes a voyage of
discovery—a journey that unveils the essence of each choice.

76
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Exploring Resistance and Brightness


Resistor’s Enigmatic Role: Amidst this exploration, the resistor emerges
as a gatekeeper—a guardian of current flow. Its role is integral, as it
modulates the current passing through the LED. An insight awaits: alter
the resistance value and witness the dance of brightness. This shift in
resistance shapes the luminous tapestry of your LED’s radiance.
Illuminating the Brightness: The resistor, as a conduit of current
control, becomes a tool for sculpting the LED’s brilliance. As you adjust its
value, the luminance of the LED responds in kind—a visual demonstration
of the interplay between resistance and brightness.

Charting the Course Ahead


A Prelude to Arduino Programming: In the chapters that lie ahead, the
curtain rises on a new act—a tale of programming with Arduino. The pages
of your journey will unfold to reveal the mechanics of translating code into
action, of sculpting logic into motion.
The Next Chapter Awaits: As your current chapter draws to a
close, a new one beckons—one that promises an exploration of wiring
components together, a journey that navigates the path to achieving
desired outcomes. Your circuit’s transformation from abstraction to reality
inches closer, as you continue to embrace the intersection of knowledge
and experimentation.
In this chapter, you’ve tasted the thrill of simulation, wielded the
power of tinkering, and understood the art of resistance-driven brightness
control. As you peer into the horizon of coding and circuitry, each step is
a brushstroke in the masterpiece of your learning journey—an opus that
unfolds with every click, every adjustment, and every spark of insight.

77
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Wiring Components
Venturing into the next phase of your circuit exploration, the canvas before
you awaits the imprint of components—a fusion of elements that breathe
life into your design. Your mission begins with the orchestration of a
symphony of parts—a breadboard, a 9V battery, a button, and the ever-
essential resistors. These building blocks are your tools, your notes, in this
composition of electronic artistry.

Crafting the Ensemble


Components Take the Stage: As you embark on this venture, each
component assumes its role in the impending performance. The
breadboard, the 9V battery, the button, and the resistors—all are poised to
contribute to the symphony that will soon resonate.
Wiring the Components: Yet, before the symphony plays, the wires
of connectivity must be woven. A task lies ahead—connecting these
components in harmony, granting them a means to interact, to exchange
energy and information. The wires, like the threads of a tapestry, are ready
to interlace.

Guided by Color and Practice


A Color-Coded Dance: In this electronic ballet, color emerges as a
guide—a language that navigates the dance of connections. Tradition
dictates a familiar practice—red wires embrace the positive terminal, while
black wires grace the negative one. The palette of hues guides the eye and
the current alike.
Battery and Breadboard Tango: The battery steps forth, its terminals
ready to waltz with the breadboard’s embrace. A connection forms—a
bridge of energy and potential. And as you’ve learned, the color of the wire
is not set in stone; it’s a canvas waiting for your artistic touch.

78
Chapter 3 Explaining the Interface and Simulating Your First Circuit

A Choreography of Arrangement
Reshaping the Landscape: As components gather, a choreography of
arrangement begins. Each element takes its place in the ensemble—a
dance that mirrors your intentions. In this intricate ballet of parts, the
scene transforms—rearranging itself to match the blueprint of Figure 3-6.

Figure 3-6. Basic circuit elements

A Glimpse of the Vision: With a deft hand and a keen eye, you mold the
components into alignment—a vision realized, a circuit formed. The scene
before you takes on the semblance of your design’s blueprint, a testament
to your manipulation of digital matter.
As you embark on this endeavor, you wield a digital brush—a brush
that paints connections and weaves pathways. The components, the wires,
and the colors are your medium—a medium that holds the promise of
illumination and interaction. Through each click, each connection, you
chart a course toward a circuit that echoes your intentions.
Connect the circuit in a configuration that LED is connected to resistor
and resistor is connected to switch. Do not forget to connect the upper and
lower rows of the breadboard to provide positive and negative voltage. The
resistance value we are going to use is 220 Ohm. Connect the LED’s second
terminal with ground, and the final circuit should look like Figure 3-7.

79
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Figure 3-7. Complete circuit

Engage the simulation by directing your cursor toward the beckoning


“start simulation” button—a digital portal to the world of virtual
interaction. With anticipation as your guide, a pivotal moment awaits as
the button’s pressure becomes a harbinger of change. When the button
yields to your touch, a symphony of electrons orchestrates a dance—a
dance that ignites the LED’s luminous presence.
In this seemingly simple interaction, a world of achievement unfolds.
A circuit’s logic translates into action; your virtual design springs to life,
affirming your understanding and mastery. It’s a digital manifestation
of cause and effect—a testament to your ability to command the virtual
realm. As the LED’s glow envelops the virtual space, it heralds not just
illumination, but the illumination of your newfound expertise. With
this successful simulation, you’ve ventured beyond the theoretical and
navigated the practical—a significant step on your journey through the
realm of circuitry and simulation.

Adding Components
Let us add some more components and see how other things work. For
executing this part, we need to add batteries and a motor. Here we will
use two 1.5V battery with the DC motor. Connect these components as
connected in Figure 3-8.

80
Chapter 3 Explaining the Interface and Simulating Your First Circuit

Figure 3-8. Battery with motor

When you press the start simulation button, you will see the motor
rotating, and the RPMs will also be written on the motor as can be seen in
Figure 3-9.

Figure 3-9. Battery with motor

Now let us add a photo-resistor from the components which is


basically a sensor. As the name suggests, the resistance of this sensor
depends upon the light intensity. Rotate the photo-resistor in order to
make the circuit given in Figure 3-10.

Figure 3-10. Battery with motor and photo-resistor

Press the start simulation button. And click the photo-resistor; you
will see a slider as given in Figure 3-11. By moving the slider to right and
left, the amount striking the sensor is being changed. You should see the
changing motor speed as you change the amount of light. The speed of

81
Chapter 3 Explaining the Interface and Simulating Your First Circuit

the motor should be least when the slider is at the opposite side of the
sun symbol indicating the least amount of light is present for the sensor.
And the speed should be highest when the amount of light is greatest.
Congratulations, you have simulated your first interactive circuit design in
Tinkercad.

Figure 3-11. Photo-resistor with its slider

Till now, we were suing two 1.5V batteries, but we can alter the power
given to the motor by changing the batteries. Go to the components,
and select the basic components category; select one 1.5V cell. Click the
cell and you will see a menu containing different options related to the
battery. You can change the number 4, and you will end up having the
configuration given in Figure 3-12.

Figure 3-12. Four 1.5V cells

Reconnect the circuit as given in Figure 3-13 and start simulation


again. Here with this circuit arrangements, you should see more RPMs as
compared to the one you saw in two battery case. Don’t worry if you have
not noted the value; you can simply click on the batter, and change the

82
Chapter 3 Explaining the Interface and Simulating Your First Circuit

number of batteries parameter to 2, 1, and again 4 and you will see the
difference. More voltage causes greater speed, and lesser voltage results in
low speed.

Figure 3-13. Motor, photo-resistor, and four battery cells

For you own learning, you can change the type of the battery and see
the results; you can also play with other options of different components.
Happy learning!

83
CHAPTER 4

Breadboard and
RGB LEDs
Now that we have introduced you with the electronic components and
Tinkercad, we can move forward and make simple circuit with a unique
type of LED called RGB LED. This unique LED can glow in three different
colors, red, green, and blue. In this chapter, we will talk about breadboards
and RGB LEDs mainly and see how helpful the tool Tinkercad is.
A breadboard is a powerful prototyping tool that will let you take
your electronic skills to the next level. With it, you can connect many
components together, so let us learn how to use it by testing out a special
type of LED called an RGB LED. First create a new design. Go to the
basics, search for breadboard, and drag a breadboard. You will see a small
breadboard: a mini breadboard and a full-size breadboard as can be seen
in Figure 4-1.

© Ashraf Said Ahmad AlMadhoun 2023 85


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_4
Chapter 4 Breadboard and RGB LEDs

Figure 4-1. Different types of breadboard in Tinkercad

You need to add the full-sized breadboard to the workspace. If you


rotate it, you will see two columns on each side called power rails. They are
marked with minus and plus signs. These columns are meant to provide
power to your components on the breadboard and are connected to the
power source. If you hover over any of the holes in the column next to the
plus symbol on the breadboard, the entire column turns green. Note that
you do not need to click on the holes; you just place your cursor on one
of the plus or minus sign’s hole. The column turning green indicates that
all the holes in the column are connected to one another. Which means
if you connect the supply in one of the holes, you can take out the power
from any of the other holes in the same column. You can see the same
phenomenon for both plus and minus columns in Figure 4-2.

86
Chapter 4 Breadboard and RGB LEDs

Figure 4-2. Full-sized breadboard with + and – power rails

Connect a 9V battery in the workplace. Then rotate and set it below


breadboard as shown in Figure 4-3. Connect the positive terminal of the
battery to plus in the breadboard and negative terminal of the battery to
the minus sign on the breadboard, and change the color of the wires as red
(positive) and blank (ground) as illustrated in Figure 4-4.

Figure 4-3. Battery with breadboard

87
Chapter 4 Breadboard and RGB LEDs

Figure 4-4. Connection of positive and negative terminals of


the battery

Take a closer look on the breadboard, and you will see alphabets on
the corners and numbers on longer sides of the breadboard indicating
rows and columns. You can hover over the holes, and the green connected
line will indicate the connection between certain holes which can be seen
in Figure 4-5. The lines from A to E and F to J are connected, but E and F
are not connected with each other.

Figure 4-5. Alphabets and numbers on the breadboard

88
Chapter 4 Breadboard and RGB LEDs

Now add the RGB LED and some resistors in the design. Search LED
RGB from the search bar and drag into the workspace. Rotate it so that
each pin is in a separate hole on the breadboard. The four pins are red,
green, blue, and cathode which can be seen by bringing the cursor onto
each pin of the LED. Now we will add a resistor to the cathode leg and
connect resistor’s other terminal with the ground on the power 480 Ohm,
and the circuit will look like Figure 4-6.

Figure 4-6. RGB LED with resistor on breadboard

As we saw it earlier that the gap between the two sides of the
breadboard separates the connection, we will make use of it while
connecting the push button. Push button is a momentarily switch, which
makes connection momentarily when pressed. Search a push button from
the search bar, and connect it onto the breadboard such that two legs
(1a and 2a) are on one side of the gap and other two (1b and 2b) are on
the other side preventing to get short. Connect one side with the positive
supply and other side of the button to the red pin of the LED as illustrated
in Figure 4-7.

89
Chapter 4 Breadboard and RGB LEDs

Figure 4-7. Push button connection

After clicking the Simulate button, press the pushbutton, and the LED
should turn red whenever the button is pressed. Once it is done, add two
more pushbuttons, and connect them to green and blue pins of the LED as
shown in Figure 4-8. On pressing each pushbutton, one of the three colors
of the LED should glow. This is how we simulated the RGB LED with the
help of one resistor, a batter, and three pushbuttons turning on each light
at a time.

Figure 4-8. RGB LED circuit

90
CHAPTER 5

Ohm’s Law
It is high time that we learn about a fundamental concept in circuit
designing which is known as Ohm’s law. In this chapter we are going
to discuss about its concept and its application to safely light up a
LED. Figure 5-1 shows a simple circuit that will be used for demonstration
purposes in this chapter, and it contains only four components, battery,
resistor, LED, and a switch. You should know that electric current flows
from the positive terminal of a power source, i.e., a battery, to the negative
terminal completing its path. This is denoted by “I” and demonstrated by
a dashed arrow in Figure 5-1, and we can the direction of the current as
arrow is headed from the positive to negative terminal. Another important
and related concept of electricity is voltage. When current flows through a
component like LED or resistor, there is an associated change in potential
energy across that component; this potential difference is known as
voltage denoted by “V” in Figure 5-1. The amount of voltage drop across
the component depends on its resistance which is simply the amount of
the obstruction it causes in the flow of current. Resistance can be seen
denoted as “R” in Figure 5-1. Resistance, although seems an unwanted
quantity because it hinders the flow of current, plays a very important role
in circuit theory. It makes sure that your electronic components do not
fry because of the access current in the circuit. If you directly connect an
LED with a battery, without a resistance in the circuit, your LED will be
burnt away. So adding resistance into the circuit is crucial, but how much
resistance should we add? What if we add a lot of resistance that only a

© Ashraf Said Ahmad AlMadhoun 2023 91


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_5
Chapter 5 Ohm’s Law

few milliampere of current can flow through the circuit? Your LED will
not glow then. Here is when Ohm’s law comes into play. It helps us to find
the right combination of resistance, current, and voltage. It formally states
that “the voltage across a conductor is directly proportional to the current
flowing through it.” The mathematical expression of this law is given in
Equation 5.1.

V = IR  (5.1)

where V is voltage in Volts, I is current in amperes, and R is resistance


in Ohms.

Figure 5-1. A simple electronic circuit

Let us get back to Tinkercad to see the Ohm’s law in action. Add an
LED and a battery in the workspace and connect them like Figure 5-2. the
positive terminal of the 9V battery is connected to anode and negative
terminal to the cathode of the LED. Press Start Simulation button to see
what will happen with our LED.

92
Chapter 5 Ohm’s Law

Figure 5-2. LED and battery

As expected, the LED seems damaged, and if you hover over the LED,
the message says that current through the LED is 915 mA while absolute
maximum is 20 mA. So, it has too much current which it could not handle
and thus damaged. This scenario can be seen in Figure 5-3.

Figure 5-3. Damaged LED

93
Chapter 5 Ohm’s Law

What do you think how can we prevent this from happening? You have
guessed it right; we are going to employ Ohm’s law here. We have voltage
of 9V, and LED can safely handle a current of 20mA (0.02A). So, we put
these values in the formula to calculate the resistor value that can help us
save our LED from damaging.

V = IR

R =V /I

R = 9 / 0.02

R = 450 Ohms

The resistance that we need is 450 Ohms for this circuit. This means
that if we want to ensure that there is only 20 mA of current flowing
through the LED, we need to add a resistor with a value of 450 Ohms to
our circuit. Let us check this out in simulation by adding a resistor to the
circuit, and it will look like Figure 5-4.

Figure 5-4. Complete circuit

94
Chapter 5 Ohm’s Law

As our next step, we click on Simulation button, and see that the LED
turns red without getting damaged by the excessive current. Let us see if
we reduce the resistor value from 450 Ohms. In Figure 5-5, we can see that
we add 10 Ohms, and the LED still blows away because there is 395 mA
current across it while the maximum is 20 mA.

Figure 5-5. Resistor and LED

What do think will happen if we change the places of LED and resistor,
like if we connect the resistor at cathode instead of anode of LED? It
actually does not matter whether the resistor comes before or after; either
way it will limit current flow, but it may not be true for other cases and
arrangements of circuit elements. You can test this out for yourself if you
want. Did you notice how the color bands on the resistor change when we
change their values? If not, then you can quickly change the resistor value
and see it yourself. This is called color coding of resistor. All of these color
bands represent some value and together they make the overall value
of the resistor. There exists a table representing the associated values of
different colors on a resistor. It is up to you now to search it yourself. Happy
learning!

95
CHAPTER 6

Series and Parallel


Circuits
In this lesson, we will talk about series and parallel circuits. We will learn
about two fundamental types of circuits, series and parallel circuits, and
find out how to apply them most efficiently to light up multiple LEDs. Let
us start with the series circuits. Let us say we have a circuit with a single
LED, but we know we want to be able to light up more than one LEDs. Your
first thought may be to add another LED directly to the circuit. Changing it
to an existing LED circuit and you are thinking why not. Create new circuit
in Tinkercad from the green button given in Figure 6-1.

Figure 6-1. Tinkercad workspace

© Ashraf Said Ahmad AlMadhoun 2023 97


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_6
Chapter 6 Series and Parallel Circuits

Let us add one LED. Now let us add another one. Then add a 3V
battery and rotate it like Figure 6-2. Then let us a meter to measure the
voltage and current through the circuit. For this, add multimeter once, and
then copy and paste it or add another one.

Figure 6-2. LEDs and battery cell

Now connect these elements together as given in Figure 6-3. You can
change the wire color to red and black to specify different terminals and
connection as in Figure 6-3. The rule for connecting the multimeter is
different for measuring voltage and for measuring current. The meter
to measure voltage is also known as “Voltmeter,” and the meter used
to measure quantity of current is called “Ammeter.” With this, we can
move on to the connection rule. As for voltmeter, we need to measure
the voltage, we connect with the same two leads of the LED as the above
multimeter (one on the left side) is connected in Figure 6-3. For measuring
Ammeter, we need to break the circuit where LED is connected; connect
one terminal of the meter to the LED and the other terminal to the point
where we broke the circuit. In our case, the break point is the positive
terminal of the battery, so the connections would look like ones given
with the multimeter on the right side in Figure 6-3. Surprisingly, we have
created a series circuit in Figure 6-3. By definition, a series circuit is one in
which components are connected end to end, and there is only one path
of the current. If we closely see the circuit in Figure 6-3, the LEDs, battery,

98
Chapter 6 Series and Parallel Circuits

and a multimeter are connected in series, as their one leg is connected to


one component and the other is connected to the other. In series circuits,
the current through each component is the same, but the voltage may vary.
But in our case, we have used only LEDs and they are both alike, so the
voltage will also be the same. We have connected multimeters to measure
current and voltage through this series circuit. In the figure, you can
see that on each multimeter, on the right side, there are letters A, V, and
R. These are for measuring current (A), voltage (V), and resistance (Ohms).
You must make sure that you choose the right quantity by clicking on the
multimeter.

Figure 6-3. Series ciruit

Run the simulation and you will see the results similar to Figure 6-4.
We can see that the voltage is 1.5V, and the current seems to be very low
as 0A. This configuration is called series, where we have a single path for
current. The current enters from positive terminal of the battery, enters to
the first LED, leaves the first LED, enters the second one, and then leaves
the second LED to back to negative terminal.

99
Chapter 6 Series and Parallel Circuits

Figure 6-4. Simulation result

Now, let us talk about the second part of this chapter, parallel circuit.
Let us add the necessary components. We need four LEDs, a battery, and a
multimeter like Figure 6-5.

Figure 6-5. Circuit components

Wire up the LEDs in parallel circuit such that both the leads of all
LEDs should be connected to each other. The parallel circuits are those in
which there are multiple paths for current, each for each component. For
example, in our case, we have four LEDs; there must be four paths for the
current. If you see the circuit, each LED is directly connected to the battery
cell as can be seen in Figure 6-6.

100
Chapter 6 Series and Parallel Circuits

Figure 6-6. Wiring of the circuit

Now, change the color of the wires as given in Figure 6-7 to indicate
the positive and negative connection of the supply. Unlike the series
circuit, the current goes from the battery and comes back to it after moving
through one LED only. In parallel circuits, the voltage is same across all
the components. So, we can measure voltage only across one component,
and we will know the voltage across all. In Figure 6-6, we have connected
a multimeter as ammeter to measure the current through an LED as the
current varies in parallel components, but as we have connected the same
components in this circuit, the current will also be the same.

101
Chapter 6 Series and Parallel Circuits

Figure 6-7. Parallel circuit

Do not forget to change the multimeter setting to Ammeter; otherwise,


it will show some garbage value in volts. Now run the simulation to see
the results given in Figure 6-8. The LEDs take around 22.6 milli Ampere to
light up.

Figure 6-8. Simulation result

It is now time to measure the voltage across the LEDs. Connect a


multimeter as voltmeter as given in Figure 6-9.

102
Chapter 6 Series and Parallel Circuits

Figure 6-9. Voltmeter connection

Now run the simulation, to see the measured voltage and current.
The voltage is around 2.10V. The voltage across each LED will be the same
because of the parallel connection.

Figure 6-10. Voltage and current measurement

Figure 6-11 shows the running simulation of both series and parallel
circuits with measured voltage and current.

103
Chapter 6 Series and Parallel Circuits

Figure 6-11. Series and parallel circuit

The main difference between a series and parallel circuit is that series
circuit has only one path between the positive and negative terminal of
the battery, but the parallel circuit has its own separate path between the
positive and the negative terminal.
Now you have learned about some of the basic differences between
series and parallel circuits. You can continue tinkering by practicing
hooking up additional LEDs in this circuit. You can try changing the
battery type or adding additional batteries in series to remember voltage
should add up in a series circuit. You may have to adjust the resistor value
or add a resistor in some cases to make sure that your circuit is running
effectively and correctly. If you closely see, there is a warning on the LED
due to excessive current. If you want to get rid of this warning, you can add
a resistor. Let us add a 100 Ohm resistor. Now as you can see in Figure 6-12,
we no longer have any warning in here.

104
Chapter 6 Series and Parallel Circuits

Figure 6-12. Added resistor in the circuit

But since we did not take the Ohm law in the previous lesson, let
us measure how much of the resistor we need to use. Here we have a
3V power source, and we know that we only need 20 mA to go through
this LED.
So, by Ohm’s law, V = I*R, and thus, R = V/I and by putting V=3V and
I=20mA. Thus, R = 3/0.02 equals to 150-ohm resistor to make sure that our
LED were lighting up correctly. I hope that you now have a clear idea about
series and parallel circuits.

105
CHAPTER 7

Arduino Output
Basics
Have you ever been curious how each light of the traffic light gets turn on
and off for a particular time duration? If yes, then this chapter is for you in
which you will first learn how you can control the blinking of an LED, then
learn how to handle multiple LEDs and their on and off timing, and at the
end, you will learn to control the brightness of the LED. We will learn all
these by creating circuits on the Tinkercad platform.

Arduino Digital Output: LED Control


Let us control the blinking of the LED by using Arduino. Arduino Uno,
LED, and resistor are required to control LED blinking. We will create
our circuit in Tinkercad. First, place all required components from the
component tab into the Tinkercad workspace. Let us make a circuit.
Connect the cathode of LED to the ground pin of Arduino as mentioned
as GND on the Arduino board and the anode of LED to the resistor, and
connect another end of the resistor to digital pin 13 of Arduino as shown in
Figure 7-1. In real life, the LED’s long and slightly curved leg is the anode,
and the straight leg is the cathode. Carefully, visualize the resistor value
by reading its strip colors, as we can see color code is brown, black, red,
and gold which is equal to 1k ohms ±5 %. Let’s assign a color to wires, set

© Ashraf Said Ahmad AlMadhoun 2023 107


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_7
Chapter 7 Arduino Output Basics

the red color to the anode of the led and wire connected to digital pin 13,
and set the black color to the cathode of the led. Now run the simulation.
What do you visualize? LED is blinking, and its blinking duration is
decided by the default code of Arduino. We will soon see how it is getting
on and off and how we can change its on and off duration, but before that
let’s understand the placement of components. If you reverse the LED
connection by connecting its anode to the ground and cathode to a resistor
which is followed by digital pin 13, your LED would be paralyzed because
its legs get connected in a certain way. Although the placement of the
resistor does not matter, you may connect it between the cathode of LED
and the ground or in the same way as shown in Figure 7-1. The resistor is
needed to limit the flow of current that will prevent LED from burning.

Figure 7-1. Connect LED with Arduino digital pin 13

Now let’s understand how LED is blinking in a certain way and how
can you control it in your desired way. So, in the upper tabs part as shown
in Figure 7-2, you can see there is a drop-down menu mentioned as block
or text or block + text any of the abovementioned would appear to you in
your Tinkercad platform. Once you click the blocks option, you will see
multiple options that would be visible to you, different colors for each
block set like blue for Output, Control, green for Math, black for Notation,

108
Chapter 7 Arduino Output Basics

and so on. If you hate coding, you can control your output just by using
these blocks. You can click any of these, and you get a heap of options
here as you can see all that you need to do we input and output is simply
drag and drop. As you can see, there are already some blocks connected
in a certain way, and it is showing the default code of Arduino that is
controlling the LED connected to digital pin 13 of Arduino.

Figure 7-2. Blocks arrangement showing how blinking of the LED is


controlled

Now let us dive deep and understand what is written for us. In blue
blocks you can read blue blocks as set built-in LED to high or low is
written. From the drop-down, you change its state to either high or low.
High means logic 1 or positive voltage signal, and low means logic 0 and
Ground. And orange blocks are control blocks by using them; we add the
delay mentioned as wait in Figure 7-2; 1-sec delay is set high. From the
drop-down option unit from secs to milliseconds can be changed and
can write the wait value instead of 1, vary the delay value, and run the
simulation you can visualize the on and off period of LED. As you can see
here, everything is working just fine. You can connect the blocks logically
the way you want just by dragging existing blocks to the trash and dragging
new blocks and drop into the workspace and then connecting as you want.

109
Chapter 7 Arduino Output Basics

Now if we go to the text area, you can see that we have this code
written for us as shown in Figure 7-3; this code is written concerning the
arrangement of blocks as we saw earlier. So, when you draw a block, it will
turn to code and burn it to this algorithm board.

Figure 7-3. Text for coding the Arduino

In the text, you can see the void setup to set the pin mode of Arduino
either as input or output. Here, pin 13, i.e., LED_BUILTIN, is set as the
output pin which means that we can send signals from the Arduino board
to this pin and do not receive signals from it. Then in the void loop, we
write the code that we want to repeat forever; digitalWrite(LED_BUILTIN,
HIGH) sends a digital signal 1 to piPIN3 which will turn on the LED; the
delay of one thousand minute seconds which means one second is written
as we added in the block area, and digitalWrite(LED_BUILTIN, LOW)
sends a digital signal 0 to PIN 13 which would turn off the LED. The on-­
and-­off period is determined by delay. Now we have seen how the blinking
of the LED is controlled by opening this text and blocks.
What you need to do now is start this thing out for yourself. You can
easily download the code from the download icon beside the blocks menu.
You can open the downloaded code by Arduino IDE as shown in Figure 7-4
and then burn it to an Arduino board, and see how it works on our real-life
Arduino board.

110
Chapter 7 Arduino Output Basics

Figure 7-4. Arduino IDE

You can also add libraries in your Tinkercad code. To see available
libraries, click on the library icon; some of the libraries are shown in
Figure 7-5.

Figure 7-5. Library icon showing some of the libraries available on


Tinkercad

111
Chapter 7 Arduino Output Basics

 rduino Dealing with Multiple LEDs


A
and Breadboard
In the realm of exploration, where wires become bridges between worlds
and components blend into a symphony of electrons, we delve into the art
of controlling multiple LEDs with Arduino’s guiding hand. As we journey
through this section, we shall learn to orchestrate the dance of light using
the canvas of a breadboard, weaving together LEDs, resistors, and the
Arduino Uno.
With anticipation, we lay the foundation of our circuit. The stage is
set—a collaborative ensemble of an Arduino board, three LEDs, three
valiant resistors, and a breadboard. This assembly of elements shall
transform into an intricate tapestry of illumination.
As we bring power to the forefront, the breadboard’s power rail
becomes a stage, hosting the grand entry of 5 volts and its accompanying
performer, the ground wire. In a visual spectacle of color, red signifies
vitality as it breathes life into the 5-volt power stream, while black
embodies the grounding connection that anchors our ensemble.
With the curtain raised, our LEDs take center stage, each waiting for
its cue. One by one, they align—a trinity of red, yellow, and green. As the
script commands, each LED stands adorned with a 220-ohm resistor, a
shield against the torrent of current. These resistors become the silent
guardians, ensuring a delicate balance between luminance and longevity.
They unite with the digital pins of destiny—pins 11, 12, and 13—bridging
the gap between the ethereal and the tangible.
The cathode, the LED’s source of light, finds kinship with the ground
rail—a common realm for all three performers. The anode, eager to
illuminate, seeks companionship with its dedicated resistor and digital
pin—a partnership that holds the promise of vibrant display.

112
Chapter 7 Arduino Output Basics

Amidst this arrangement, a circuit is born—each LED poised for


expression, each resistor a guardian of equilibrium, and each digital pin a
conduit of control. The scene is set, the players ready.
Behold, the stage, a tapestry of wires and components, is transformed
into an arena of illumination, where light dances through diodes and
resistors stand sentry. Our circuitry, meticulously constructed, stands as
a testament to the art of harmonizing control and creativity, guided by
Arduino’s insight.
So, in this journey, we find ourselves at the precipice of understanding,
ready to embrace the interplay of electricity and artistry. The circuit is
more than wires and components—it is a canvas where LEDs become
performers, resistors become guardians, and the Arduino becomes the
maestro of light. As we venture forth, we shall wield this knowledge to
bring forth new realms of illumination, shaping our own narrative in the
symphony of electrons.

Figure 7-6. Arduino with multiple LEDs and breadboard

113
Chapter 7 Arduino Output Basics

In the realm of coding, the stage is set for our LEDs to take their cues,
their choreography scripted with lines of logic. As the curtain rises on the
“Code” tab, we are presented with two distinct paths to wield our artistic
control—text or blocks, each poised to translate our intentions into the
language of electrons.
Now, let our intention take form. Imagine a scenario where one LED
must bask in its luminance while its companions await their moment
in the shadows. With this vision in mind, we embark on crafting the
symphony of commands that shall animate our LEDs.
As the script unfurls, a clear pattern emerges—akin to the rise and
fall of performers on a stage. Each section of code is an act, a sequence of
commands carefully orchestrated to manifest our vision. Picture the stage:
three LEDs, waiting in the wings, their brilliance poised to shine.
In this act, the prologue of “void setup” plays out—a prelude to
the grand performance. With each line, a pin’s role is defined—a stage
manager allocating cues to performers. As we traverse the threshold
of the “void loop,” our script takes on a rhythmic cadence, a loop that
encapsulates the essence of our story.
Within this loop, the “digitalWrite” command becomes our
conductor’s baton, summoning a single LED to grace the stage. As the
first LED takes its bow, it bathes the scene in its luminous glow, its
performance set to last precisely 1000 milliseconds. But the stage is vast,
and other LEDs await their cues.
Like clockwork, the command “delay” invokes a hushed pause—a
moment of anticipation before the next performer emerges. As the LED’s
brilliance recedes, another light takes its place, basking in a one-second
spotlight, its aura pulsating through the circuitry.
The script continues its waltz, each LED taking its turn in a sequence of
brilliance, a dance of light and dark, illumination and obscurity. And as the
loop draws to a close, the cycle begins anew—LEDs ascending the stage in
a harmonious rhythm, a symphony of illumination.

114
Chapter 7 Arduino Output Basics

And so, dear scriptwriter, you stand at the crossroads of text and code,
poised to breathe life into your electronic narrative. Each line a note, each
command a step, as your LEDs perform their roles in this grand electronic
ballet. With every iteration of the loop, the LEDs enact their dance—a
dance crafted by your intentions, shaped by your code, a dance that
exemplifies the interplay of creativity and technology that Arduino brings
to life.

Figure 7-7. Code to control multiple LEDs

As we delve into the intricate lines of code, a narrative of control and


illumination unfolds, intricately woven into the fabric of Arduino’s logic.
Within the “void setup” realm, a symphony of pin configurations takes
shape—pins 11, 12, and 13 are bestowed the role of digital outputs, ready
to serve as conduits of our commands. Each pin, a potential gateway to a
realm of illumination, stands poised for its cue.
In the heart of the “void loop,” a choreography of commands unfurls. It
is here that our intentions manifest as digital signals, coursing through the
veins of wires and components. As the curtain rises, the initial state of all
pins is set to logic 0, casting a canvas of darkness.
With the deftness of a maestro, the “digitalWrite” command takes
center stage, sending forth a high logic signal to the first actor—pin 13. A
spotlight of brilliance illuminates the red LED, its radiance resonating for
precisely 1000 milliseconds, before gracefully dimming to obscurity.

115
Chapter 7 Arduino Output Basics

As this luminary recedes, another emerges from the wings—the yellow


LED, waiting in the wings at pin 12. Its performance is orchestrated
with equal precision—a one-second reign of illumination, followed by a
moment of repose.
The grand finale draws near as the baton of control passes to pin 11—a
green LED poised to captivate the audience. A crescendo of brilliance
engulfs the stage for another fleeting second, painting the canvas with
hues of green. And yet, this performance is far from finite, for the loop shall
continue to weave its tale ad infinitum. As the green LED gracefully yields,
the cycle begins anew—the red, yellow, and green LEDs taking their turns
in the spotlight, a dance of light and shadow.
Now, as the curtains of simulation rise, this symphony comes to
life. The red LED, a beacon of vibrancy, illuminates its surroundings,
followed by the warm glow of yellow, and the verdant allure of green.
Each LED’s performance is marked by a distinct duration, a choreography
of light orchestrated by the digital commands. As the sequence unfolds,
an intricate interplay of darkness and illumination is etched into the
canvas of the breadboard—a canvas transformed into a realm of dynamic
expression.
And so, dear explorer, you witness the magic of multiple LEDs, each
awaiting their cue to shine upon the stage. The Arduino’s code and your
circuitry collaborate in a dance of orchestrated brilliance, showcasing the
harmonious marriage of technology and creativity. In this ever-revolving
loop, the LEDs take their turns to captivate, mesmerize, and relinquish the
spotlight, reminding us that within the realm of electronics, every line of
code and every connection is an opportunity to craft a symphony of light, a
testament to the artistry that Arduino brings to life.

116
Chapter 7 Arduino Output Basics

Arduino Analog Output: Fading LED


Within this segment of our exploration, we shall embark on a voyage into
the realm of LED modulation, where the luminous threads of creativity
intertwine with the versatile analog pins of the Arduino. Prepare to delve
into the art of crafting LED brilliance by harnessing the subtleties of analog
signals. While we have previously mastered the art of conveying binary
signals through digital output pins to illuminate LEDs, the horizon now
beckons us to wield the power of Arduino’s analog outputs for a more
nuanced approach.
In the symphony of electronic orchestration, we encounter the concept
of “fading.” Much like the ebb and flow of musical notes, fading entails
adjusting the luminosity of an LED, invoking a mesmerizing dance of
light. Yet, what sets this endeavor apart is the utilization of select digital
pins adorned with a waveform-like symbol, signifying their aptitude for
producing analog signals.
Picture the Arduino Uno before you, adorned with a constellation
of pins. Amidst them, a distinctive symbol adorns a subset—digital pins
3, 5, 6, 9, 10, and 11. These pins, much like enchanted conduits, possess
the remarkable ability to emulate analog signals—a seamless transition
between the binary realms of high and low. These pins stand ready to
serve as a gateway to the realm of analog expression, where gradients of
luminosity are meticulously woven.
The beauty of this technique lies in its potential to orchestrate LED
brilliance with the finesse of a maestro. No longer constrained to stark
illumination or complete darkness, we find ourselves endowed with the
power to navigate the spectrum of light, painting our canvas with gradients
that evoke emotions and atmospheres.
As we stand on the threshold of this creative journey, we are armed
with the knowledge that the aforementioned pins shall serve as our
conduits to this world of analog modulation. With every pulse of code,
every subtle alteration in voltage, we shall wield the power to craft dynamic
visual narratives that transcend the confines of mere illumination.
117
Chapter 7 Arduino Output Basics

So, with the stage set and the analog pins as our allies, let us embark on
this journey of LED modulation—a voyage where the symphony of digital
precision blends seamlessly with the artistry of light, creating a harmonious
dance of luminescence that speaks to the very essence of creativity.
In the vast and intricate tapestry of electronic exploration, we find
ourselves on a journey to craft circuits—exquisite tapestries of wires,
intricate components, and the harmonious interplay of electrons. It is a
symphony of technology and creativity, where the mundane becomes
the extraordinary, and the abstract transforms into tangible reality. With
Tinkercad as our virtual canvas, we are poised to infuse existence into our
digital dreams, to orchestrate the ethereal ballet of light and energy that
resides within the realm of electronics.

Figure 7-8. Pins with wave sign are analog output pins of Arduino

As we commence this digital artistic odyssey, the foundation is laid—


the Arduino board takes center stage, a conductor of computational
prowess. Beside it, the breadboard stands as a platform of limitless
connectivity, where pathways of possibility unfurl. And there, our
protagonists emerge—the LED, a luminescent luminary, and the resistor,
a steadfast sentinel, both awaiting their cues in the grand performance of
electronic artistry.

118
Chapter 7 Arduino Output Basics

Figure 7-9. LED fading using Arduino

Connections unfurl, wires weave their intricate dance, and


components find their rightful places—a delicate LED finds its home
on pin 9, its luminous spectrum destined to manifest in hues of vibrant
yellow. The stage is set, the actors in position, as power wires—one ablaze
in vivid red, the other in solemn black—usher forth the energies that shall
animate this digital canvas.
In this symphonic narrative, an oscilloscope takes its place—an
enigmatic observer, a portal to the unseen realms of voltage and waveform.
Wires resplendent in yellow and dignified in black bridge the realms,
ready to convey the enigmatic messages of voltage fluctuations that course
through this intricate web of connectivity.
And so, the tableau unfolds, as the circuit springs to life, an embodiment
of our creative vision. Amidst this dance of electrons, colors, and
connections, we stand at the crossroads of imagination and technological
prowess. A mere click ignites the choreography of illumination, unveiling
the radiant artistry of our circuit’s dance—a homage to our ingenuity and a
testament to the marvels of electronic expression.
Upon this virtual canvas, we lay the foundation—a tapestry of potentiality.
Behold, the Arduino board takes its place, a sentinel of computation. Beside
it, a breadboard, a sanctuary for connections and dreams. Our actors await
their cues—the LED, a luminescent muse, and a resistor, a silent guardian.

119
Chapter 7 Arduino Output Basics

Connections come to life—an LED finds its abode, nestled upon pin
9, its radiance destined to be painted in hues of yellow. The stage set, the
players take their positions—the wires of power, one in resplendent red,
the other in steadfast black, grounding the realm in potential.
An oscilloscope emerges—an enigmatic observer, its purpose to unveil
the arcane voltages coursing through the circuit’s veins. Wires of yellow
and black once more, a chorus of electrons ready to divulge their secrets.
As our circuit unfurls, its artistry akin to Figure 7-8, we stand at the
precipice of simulation. An LED poised to respond, to dance, to illuminate.
Voltage waves yearning to be seen, to tell their tales of rise and fall.
The digital realm reverberates with anticipation. The connections,
the colors, the components—they are the palette of creation. In this
symposium of electrons, we transmute concepts into reality, and with a
click, a circuit springs to life—a testament to our virtual craftsmanship, a
harbinger of enlightenment.
The canvas of creation beckons, and we stand at the threshold of
realization. With a palette of blocks, we shall weave the tapestry of our
intent. As novice navigators, we turn to the “block mode,” a gentle breeze
to guide us through the labyrinthine corridors of code.

Figure 7-10. Drag count up block, rename variable name, and set its
max and min count

120
Chapter 7 Arduino Output Basics

In the realm of control, a block awaits—the “count-up” block—an


incantation of iteration. A journey to traverse, a variable to embody—the
variable “brightness” ascends to prominence, its name inscribed upon the
altar of transformation. A name, once “i,” now resonates with purpose.
We embark upon the act of transmutation—a right-click, a name
altered. From “i” to “brightness,” a cosmic rebirth transpires. The blocks,
once a medley of potential, now align with our aspirations, a symphony of
intent woven into the very fabric of creation.
As the sun sets behind the horizon of uncertainty, the count-up block
beckons us forward. The variable “brightness,” now an embodiment of
luminance, emerges from the shadows of ambiguity. With each iteration,
it traverses the realms of possibility, its value ascending to the zenith of
brilliance.
And so, with a click, a drag, a drop, our narrative unfolds. The blocks,
once scattered fragments, now congregate in harmony, their arrangement
a reflection of our design. The “count-up” block carries our hopes and
dreams, guiding the variable “brightness” on its journey of revelation.
In this sanctuary of creation, code is not merely code—it is a language
of possibility, a gateway to realization. As we manipulate the blocks, we
sculpt the very essence of our desires, beckoning the LED to transcend its
confines and radiate with newfound splendor.
With each action, each interaction, the canvas evolves. The variable
“brightness” dances to the rhythm of the count-up block, an ode to
exploration, an anthem of transformation. And as the blocks converge and
coalesce, we glimpse the power of creation—a power that lies within each
line, each pixel, each intention.
With a sense of accomplishment, we survey our handiwork—a
constellation of blocks, a constellation of ideas, a constellation of light.
In this world of programming, where blocks are our brushes and code is
our canvas, we manifest the intangible, sculpting a reality that bridges the
realms of imagination and expression.

121
Chapter 7 Arduino Output Basics

In the realm of code, a symphony of variation unfolds—a dance of


numbers, an evolution of luminance. Within this rhythm, a counting loop
emerges—a maestro orchestrating the transformation of values. Imagine, if
you will, a variable named “brightness,” a chameleon of intensity, poised to
traverse the spectrum from abyssal darkness to resplendent radiance.
From the realm of output, a block materializes—the “set pin” block—
an enabler of electronic metamorphosis. A conduit through which digital
directives flow, imbued with the power to mold voltages and kindle LEDs
to life. And there, in the midst of this intricate choreography, the variable
“brightness” makes its entrance—an avatar of transformation.
A nexus is formed—a union of code and hardware—a digital soliloquy
delivered through the vessel of pin 9. The variable “brightness” steps forth,
offering itself to the pin value, a conduit of change. And so, as the counting
loop unfurls, the variable “brightness” shifts, metamorphosing from 0 to
255—a journey from obscurity to luminescence.
Pin 9, once a dormant bystander, now assumes a role of great
significance. Its destiny intertwined with the variable “brightness,” it
becomes a harbinger of light. With each iteration of the counting loop, a
pulse of transformation courses through the pin, dictating the brilliance of
the LED—a ballet of photons that dances to the rhythm of code.
The interplay is exquisite—a fluid dialogue between the digital
realm and the tangible world. As the loop advances, so does the value of
“brightness,” a cascade of brilliance that mirrors the ascent of dawn. The
LED, a silent partner, responds to this fluctuating embrace, its luminosity a
canvas painted with shades of mathematical elegance.
In this grand performance, the code is both conductor and
composer—an architect of illumination. It paints a portrait of change, of
variation, of the symphony between abstract logic and physical reality.
And as the counting loop orchestrates its crescendo, the LED responds
with a luminous flourish—an embodiment of the creative potential nestled
within the heart of programming.

122
Chapter 7 Arduino Output Basics

Figure 7-11. Set pin number and its current value

With a mere right-click, a symphony of duplication unfolds—an act


of cloning, as it were. Behold the newfound twins, an exact replica of
their predecessor blocks. Placed side by side in harmonious unison, their
purpose remains twofold—to bestow brilliance upon the LED canvas, a
partnership of illumination and shadow.
And so, these doppelgangers embark on a journey of variable
assignment. The variable “brightness,” a malleable vessel, awaits the
imparting of its value. Beginning at the pinnacle of radiance, a regal
255—each subsequent cycle diminishes its luminous presence by a single
quantum, progressing in a stately procession. A numerical elegy, a dance
of dwindling radiance, tracing a path from resplendence to obscurity.
Behold the orchestration, a mirror image of the original, a
simultaneous occurrence of ascent and descent. As if painting with light,
these replicated blocks mirror each other’s cadence, echoing the rise
and fall, the crescendo and diminuendo—a visual representation of a
diminishing spark.
Within this mirroring, a potent lesson emerges—an exploration of
code symmetry. Just as a dance of light plays out in perfect resonance,
so does the code’s choreography. The twins, a testimony to the beauty of
replication, represent an elegant mechanism for repetition and scalability.

123
Chapter 7 Arduino Output Basics

In this ethereal dance of duplicated blocks, we see not just a


replication of code but an echo of creativity—a reminder that in the realm
of programming, the echo of an action can ripple forth in ever-expanding
waves of complexity and artistry.

Figure 7-12. Set brightness value from 255 to 0 and add wait block

The subsequent steps involve the strategic insertion of wait blocks,


masterfully calibrated to the precise tempo of milliseconds—let’s say, an
enchanting 30 milliseconds. This calculated interlude serves as a poignant
pause between each modulation, allowing the effulgent light to grace
its allotted brightness before transitioning. A choreographed dance of
illumination, gracefully unfolding as if in slow motion.
Behold, the initial stage of the code takes shape, a symphony of
binary transitions artfully choreographed. Now, immerse yourself in the
simulation—an ethereal unveiling, akin to the dawn of light. Observe how
the LED emerges from its dormant state, gently illuminating the canvas of
your imagination, and then recedes like a fading star.

124
Chapter 7 Arduino Output Basics

Witness the orchestration, a digital overture on display. In the realm


of the oscilloscope, a square wave signal unfurls, tracing its tale of voltage
variance. First, a decisive ascent to the zenith of 5 volts, then a dalliance
between the realms of 0 and 5 volts, before descending gracefully to 0 volts
once more. This pattern of ebb and flow becomes evident, portraying the
LED’s delicate ascent and decline.
Ah, but subtlety reigns supreme. In the grand design, the tempo
itself holds a secret—a key to the LED’s cadence. What if we, as virtuosi,
choose to manipulate this tempo? By rewriting the wait value, the
narrative metamorphoses. If 500 milliseconds graces the wait blocks, the
performance elongates, rendering each phase distinct and apparent.
Yet, as artists, we hold the brush of control. In defiance of languor,
we pivot to a faster tempo, the wait value diminished. A flurry of light
ensues—a rapid metamorphosis from the darkest depths to the pinnacle of
brilliance.
Pause to consider the intricate mechanics beneath this spectacle.
Digital signals convolute into analog expressions, rendering light in its
myriad shades, from the zenith of luminosity to the nadir of darkness.
Such is the alchemy—within the bounds of a digital world, a fraction of
a spectrum emerges. This is the essence of the analogWrite command,
where fractions of the whole manifest in shimmering radiance or retreat
into the obscurity of shadow. A fraction of 100% of the 5 volts—the essence
of control etched in each microsecond.

125
Chapter 7 Arduino Output Basics

Figure 7-13. (a) Showing the full brightness mode of LED and (b)
and (c) showing how the signal across LED decreases to 0 which
results in fading of the LED

The technique harnessed in the process elucidated above bears the


name of “Pulse Width Modulation,” or PWM in abbreviation. While an
Arduino board inherently speaks in the binary language of digital signals—
conveying either high or low states—the ingenious analogWrite command
serves as the gateway to an entirely new dimension. This command ushers
forth a departure from mere on-off toggles, delving into the realm of
analog values.
Unveiling the depths of this command, you find yourself wielding
the capability to dispatch analog values—ranging not solely between the
binary extremes of 0 and 1, but encompassing an expansive spectrum
stretching from 0 to 255. Picture this digital alchemy illustrated in
Figure 7-14—an intricate dance where values intertwine to create a
symphony of gradients and nuances.
It’s akin to painting with a broad palette, where each value
meticulously selected renders a brushstroke of specific shade and
intensity. As you deploy analogWrite, the output pins of your Arduino

126
Chapter 7 Arduino Output Basics

board come alive with a spectrum of potential intensities, permitting you


to orchestrate a crescendo of luminosity, control the rotation speed of
motors, or unleash a cascade of sonic frequencies. The command thrives
as a bridge between the discrete world of digital code and the continuous
canvas of the analog realm.
Let this concept unfurl as you traverse the pathways of your Arduino
endeavors. Each value, each pulse, breathes life into your creations,
infusing them with a granularity that sets your projects apart. From the
glow of LEDs to the rhythm of motors, from the melody of sound to the
whispers of complex systems, PWM bestows upon you the power to
illuminate, move, resonate, and innovate—all by harnessing the harmony
of digital precision and analog subtlety.

Figure 7-14. LED fading code

Pulse Width Modulation, commonly known as PWM, stands as a versatile


tool in the realm of electronics and digital signal manipulation. This ingenious
technique involves the generation of an oscillating digital signal that effectively
toggles between high and low states at controlled intervals. Through the
precise manipulation of these intervals, PWM empowers us to achieve an
illusion of analog behavior, lending finesse to our digital orchestrations.

127
Chapter 7 Arduino Output Basics

Armed with the knowledge of fading and the potent capabilities of


pulse width modulation, you stand poised to venture into the realm of more
intricate Arduino exercises, each wielding the mighty analogWrite function
as its instrument of creation. Within this rich tapestry of possibilities, RGB
LEDs shine as a prime example. With the alchemy of analogWrite, you gain
the power to command the ratios of red, green, and blue light, blending
them into an infinite spectrum of vibrant hues. Through meticulously
controlling the brightness of each color, the canvas of your creation is
limitless, and the palette at your disposal knows no bounds.
But the horizons of analogWrite stretch far beyond the realms of color.
As you journey deeper into the Arduino landscape, you’ll discover that
this function can be harnessed to dictate the very rhythm of motion. The
tempo of a DC motor’s spin is but a command away, and the library of
musical notes at your disposal unfolds an auditory odyssey that’s limited
only by your imagination.
Indeed, the potential is as expansive as the universe itself. The pathway
to creation is not confined solely to the realm of code mastery. With
just a pair of blocks, you can sculpt intricate symphonies of action, each
triggered by your commands and directed by the logic you set in motion.
The bridge between code and reality has been crossed, and the fusion of
imagination and coding has unlocked a playground where the boundaries
are self-imposed and innovation knows no restraint.
Embrace this realm of boundless possibilities, for here, your creations
can be as intricate as a symphony, as vibrant as a rainbow, or as agile as
a motor’s spin. With the amalgamation of your ingenuity and the power
of analogWrite, you possess a key that can unlock doors to a world where
anything is achievable—a world where the convergence of the digital and
the tangible can bring your wildest ideas to life.

128
CHAPTER 8

Arduino Input Basics


In the vast realm of technology and innovation, the ability to command
and orchestrate actions through input signals is a cornerstone skill that
traverses a myriad of disciplines. From the intricate domains of electronics
and robotics to the fluid landscapes of software development and
automation, the art of controlling outputs based on inputs reigns supreme.
In this chapter, we shall embark on a journey of empowerment as we delve
into the mechanics of harnessing the power of input signals to govern and
direct our desired outcomes.
At the heart of this chapter lies the artistry of interaction, a dance
between input and output that forms the essence of control. As we delve
deeper, a simple yet profound example unfurls before us—an example
brought to life within the confines of Tinkercad. Here, we shall unravel
the enigma of reading the state of a humble push button, a digital
sentinel poised to deliver its message through electrical currents and
microcontrollers.
Within the corridors of code blocks, we shall weave a narrative that
transcends the boundaries of digital and tangible worlds. Through a
delicate choreography, we shall sculpt a scenario where the blinking of
an LED becomes a manifestation of our commands. The canvas we paint
is one of adaptability and responsiveness, where a mere press of a button
can trigger a symphony of actions—a paradigm that resonates across the
spectrum of technological innovation.

© Ashraf Said Ahmad AlMadhoun 2023 129


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_8
Chapter 8 Arduino Input Basics

As we voyage through this chapter, we shall unlock the gateway to


empowerment. We shall harness the potential to bestow life upon myriad
systems—be it regulating the fervor of a fan’s whir, altering the course of a
motor’s rotation, or orchestrating a host of other outputs, all guided by the
lilt of our control signals. The mastery of this skill shall be our compass,
guiding us through the realms of complex control systems, imbued with
the essence of adaptability.
In embracing the lessons of this chapter, we take on the mantle of
creators and directors of our own technological narratives. The tapestry
we weave is one of intelligence and receptiveness, a narrative where the
interplay between inputs and outputs forms the bedrock of innovation.
As we unlock the secrets of controlling outputs through input signals, we
open doors to the infinite possibilities that lie ahead—a realm where our
creations respond not just to preordained commands, but to the whispers
of change and the beckoning of user input.
In a world where every press is a catalyst and every signal a conductor,
we become the architects of dynamic systems that respond to the ebb
and flow of the environment. The symphony we compose is one of
empowerment, where intelligence and technology unite to shape a future
that is more intuitive, more responsive, and infinitely more extraordinary.

Reading Digital Input


Amidst the intricate tapestry of electronic devices, appliances, and
machinery, a quiet sentinel stands ready to spring into action at the
gentlest nudge—a push button. With its unassuming presence, the push
button is a maestro of initiation, summoning forth a cascade of events with
a mere touch. This humble switch finds its home in countless scenarios,
orchestrating actions that range from activating lights and unlocking doors
to initiating intricate processes within machinery.

130
Chapter 8 Arduino Input Basics

The essence of a push button’s magic lies in its very nature—a switch
that responds to the gentle pressure of a fingertip, akin to a whisper that
stirs a symphony. Once pressed, its innate magic comes to life. As the
physical world melds with the realms of electrons, an electrical circuit is
seamlessly woven into existence. This circuitry forms the conduit through
which a signal embarks on its journey—a signal that carries within it the
command to fulfill a predefined task or function.
Within the heart of the Arduino, digital input pins slumber, waiting for
their moment in the spotlight. These pins possess the remarkable ability to
sense the state of input signals, like an oracle interpreting cosmic whispers.
The push button’s purpose becomes clear as we bridge the gap between its
terminals and the digital input pin. The act of pressing the button forges a
connection—a dance that completes the circuit, unleashing an electrical
signal that reverberates through the corridors of the control system or
microcontroller.
A visual narrative emerges as we journey into the realm of circuitry.
Behold Figure 8-1—a crystallization of our understanding, a visual tableau
that captures the essence of the push button’s union with circuitry. An
Arduino takes center stage, surrounded by an ensemble of components—a
breadboard, resistors, a push button, and the humble LED. Each element
plays its part in crafting this electronic ballet.

131
Chapter 8 Arduino Input Basics

Figure 8-1. Connect push button and LED with digital pin
of Arduino

The intricate choreography begins with the placement of resistors—a


duet between a 120-ohm resistor and an 18k-ohm resistor. These resistors
are tasked with safeguarding the harmony of the circuit—a push-button
symphony in which stability is paramount. The pull-down resistor, the
18k-ohm guardian, finds its solace as one end meets the push button’s
terminal. Here, it reaches out to the ground—a grounding embrace that
whispers serenity into the circuit’s ears.
The LED, a luminary of our electronic stage, beckons with its brilliance,
awaiting its cue. Positioned with a 120-ohm resistor, it stands ready
to embody our code’s ambitions. The LED and its companion resistor
gracefully bridge the gap between the digital pin 13 of the Arduino and the
world of illumination.
As we traverse the corridors of code, a saga of if statements unfolds—a
narrative that hinges on the button’s whispered state. Within the realm
of code, we wield conditional statements as a scriptwriter wields words,
guiding the LED’s destiny. The question posed is simple: Is the button
pressed? If the answer is affirmative, then an enchanting sequence

132
Chapter 8 Arduino Input Basics

begins—a mesmerizing blink that paints the LED in ethereal rhythms.


The button’s command ignites the LED’s radiance, illuminating the path
ahead. Yet, if the button rests untouched, the LED remains ensconced in
darkness—a realm untouched by the button’s magic.
In the grand tapestry of this chapter’s teachings, we find the
embodiment of a synergy that spans tactile actions and digital realms. A
push button becomes more than a mere switch; it metamorphoses into a
conductor, a catalyst that bridges physical and digital worlds. It serves as
a beacon of initiation, as a testament to the art of interfacing the tangible
with the ethereal. In the labyrinth of electronic possibilities, the push
button stands as an emissary of empowerment—a reminder that a single
press can unleash a symphony of actions.
Delving deeper into this intricate web of electronic orchestration, we
unearth the rationale behind the incorporation of resistors with not only
LEDs but also push buttons. Let us embark on this exploration to fathom
the essence and purpose that underlies the conjunction of a resistor and a
push button in this configuration. What beckons our understanding here is
the embodiment of the resistor’s role as a “pull-down resistor.”
Immerse yourself in the world of pull-down resistors—a remarkable
tool harnessed within electronic circuits to ensure a stable voyage for input
signals within the realms of digital logic circuits and microcontrollers.
Imagine a scenario where an input signal, left untamed, navigates
uncertain territories when it is not under the watchful guidance of an
active external circuit. The pull-down resistor enters this narrative as
a guardian, firmly tethered between the input pin and the grounding
sanctuary. In moments of dormancy, when the input signal slumbers, this
resistor awakens to provide an unobstructed path to the ground. A path
that quells the turbulence of idle signals, paving the way for tranquility
amidst the tumult of electrical noise.
In the grand tapestry of digital circuits, inputs pulsate with the
dichotomy of high and low voltages, mirroring a cosmic dance of binary
states. Akin to cosmic bodies, inputs require stability; they yearn for

133
Chapter 8 Arduino Input Basics

definition in their state. The pull-down resistor steps onto this stage as a
master choreographer, orchestrating equilibrium when no external hand
guides the input’s motion.
The dance between resistors and input signals becomes profound
when we confront the specter of the “floating” state—an ethereal realm
where undirected inputs waltz with electrical noise, yielding erratic
oscillations between high and low states. Chaos ensues, compromising
the circuit’s harmony and injecting unpredictability into its operation. The
pull-down resistor emerges as a sentinel against this cacophony, providing
a steadfast connection to the ground that quells the unruly cacophony.
This practice, while elegant, doesn’t forsake the needs of an active
circuit. In moments when the input is called to action by an external
circuit, the pull-down resistor steps aside gracefully, allowing the external
force to assert its influence without hampering the flow of current.
In Figure 8-1, our narrative visualizes this symphony—where a push
button and an LED coalesce. When the button remains untouched, the
digital pin 2 finds solace in the grounded embrace of the pull-down
resistor, eradicating any inklings of a “floating” state. Yet, as the button’s
heart beats with intent, a path to power manifests, illuminating the LED
and bestowing upon the digital pin 2 the high state.
The real triumph of the pull-down resistor surfaces as we unmask the
veil of uncertainty that plagues a floating input. The resistor’s presence
eradicates the tumultuous dance of electrical noise, allowing the signal’s
true intent to prevail. However, the resistor doesn’t just alleviate chaos;
it fends off the intrusive cacophony of electromagnetic interference
and static electricity, safeguarding the integrity of the input signal and,
consequently, the sanctity of the output.
Let us also touch upon the counterpart—the pull-up resistor—a guardian
of a different realm. These resistors tether inputs to power, creating stability
in a world of electric symphonies. In essence, the pull-up and pull-down
resistors intertwine to bring forth a state of equilibrium, ensuring that each
input dances to the beat of certainty, devoid of noise-­induced disruptions.

134
Chapter 8 Arduino Input Basics

Venturing forth, we transition from theory to practice—coding with


intent and purpose. With a variable named “buttonState,” we traverse the
landscape of digital pins and readings. Our code weaves a narrative of
decision-making, where if-then blocks evaluate button states and LEDs
pulse in rhythm with button presses.
With Figure 8-2 as our guide, we uncover the sequence of events in
the code’s ballet. The variable “buttonState” emerges as the recorder
of button states—1 or 0, a binary whisper. The if-then block steps in as
the conductor, attuned to this dichotomy. As the button state oscillates
between pressed and unpressed, the LED’s brilliance follows suit,
illuminating and dimming in response.

Figure 8-2. Code block to read state of push button and to control the
LED blinking accordingly

As the final curtain descends on this chapter, the resonance of pull-­


down resistors reverberates. A harmonious partnership with push buttons
emerges—a delicate balance that illuminates, stabilizes, and guides digital

135
Chapter 8 Arduino Input Basics

narratives. The luminous dance between resistors and inputs, embodied


by code, captures the essence of order amidst electronic chaos, a testament
to the power of intention and design.
As the curtains of this chapter draw to a close, a final act unfolds—a
demonstration of the waltz between a push button and an LED. In the
grand theater of simulation, we witness a dance of interaction—an LED
that bows to the push button’s touch. When the button’s pressure meets
the LED’s gaze, a symphony of light commences—illuminating the digital
stage. And as the button’s embrace releases, the LED bids its luminous
adieu, returning to the shadows.
In Figure 8-3, this pas de deux is captured—a visual testament to the
code’s orchestration. The LED’s rise and fall, an ethereal manifestation of
the button’s press and release, narrates a tale of digital interaction.

Figure 8-3. Pressing push button results in blinking of LED

Through this exercise, the art of reading values as input finds its
culmination. The push button—a tangible entity—becomes a conductor
of light, initiating and extinguishing the LED’s glow. The code, woven
with the fabric of conditional evaluation, becomes the translator between
physical touch and digital command.

136
Chapter 8 Arduino Input Basics

With this achievement in our repository, a chapter concludes, but a


world of exploration beckons. Armed with this knowledge, the journey
extends into the uncharted territory of your creative canvas. The realm
of simulation and hardware awaits, inviting you to breathe life into your
ideas—transmuting concepts into reality.
Your newfound prowess with push buttons and if statements lays the
foundation for further adventures. In your explorations, consider a flip
of logic—where the LED rests in perpetual brilliance until the button’s
touch dims its glow. This inversion of interaction adds yet another layer of
dynamic control to your repertoire.
As you traverse this realm, the simple becomes the canvas for the
complex. Imagine a temperature sensor’s whisper, dictating the fan’s
cadence, or a motion sensor’s prompt, conjuring light at a room’s entrance.
The echoes of this basic example resound through myriad applications, as
it emerges as the cornerstone of intelligent, responsive systems.
In this coda, we leave you with the tools to shape the digital world.
By understanding how to command outputs based on inputs, you
gain the power to create systems that mirror your intent—adaptation,
transformation, and response interwoven into the fabric of code. Armed
with this skill, you stand at the threshold of innovation—poised to craft
solutions that bridge the gap between intention and execution.

Reading Analog Value


Venturing further into the realm of Arduino’s capabilities, we are poised
to explore the nuances of analog input—an endeavor that delves beyond
binary boundaries into the realm of gradients and subtlety. In the
chapters prior, we unearthed the art of digital input through push buttons,
encapsulating states in stark binaries of 0 and 1. However, the stage
expands, beckoning us to a grander performance—one where analog
values are not merely read, but embraced and understood.

137
Chapter 8 Arduino Input Basics

Welcome, then, to a chapter that unfolds the enigma of potentiometers


and analog input—a symphony that plays with the nuances of continuous
signals, revealing the Arduino’s prowess as a translator between the analog
and the digital realms.
In our digital odyssey, we unveil the significance of reading analog
inputs—a skill that transforms the Arduino into a discerning observer of
the analog world. In this narrative, voltage and current cease to be abstract
phenomena, instead taking on the form of digital data that the Arduino can
grasp and interpret. This interaction—where analog signals are translated
into digital values—stands as a testament to the Arduino’s ability to bridge
the worlds of physical sensors and digital command.
With every rotation of the potentiometer’s knob, a gradual evolution of
electrical signal occurs—a dance that the Arduino is poised to sense and
comprehend. This dance, rooted in analog input, opens the gateway to a
world of dynamic values, a world that pulsates and shifts in response to
our interaction.
As we approach the Arduino’s anatomy, we discover the analog pins,
nestled opposite their digital counterparts. These analog pins, denoted
A0 to A5, act as conduits for the analog signals that traverse the Arduino’s
path. They serve as the gatekeepers to the microcontroller’s analog-to-­
digital converter (ADC), an enchanting mechanism that transforms the
fluid analog world into discrete digital values.
This chapter, a journey of exploration, heralds a new dimension in
our Arduino saga. It introduces us to the realm of continuous signals and
infinite variability—analog signals that surge through the circuits and
settle within the digital microcosm. With the flick of a potentiometer’s
knob, we unravel a tale that transcends the confines of binary states—a tale
of Arduino’s role as a mediator between the tangible and the digital, the
analog and the discrete.
To conclude, the mastery of analog input ushers us into a realm
of infinite possibilities. The potentiometer becomes our instrument
of interaction, allowing us to navigate the gradients of analog voltage.

138
Chapter 8 Arduino Input Basics

Arduino’s analog pins serve as portals that channel these signals, while the
ADC orchestrates the grand translation into digital data. As we traverse
the six analog pins, we open doors to a world where Arduino’s capabilities
extend beyond the confines of on and off, embracing the rich nuances of
continuous signals. This chapter unveils Arduino’s metamorphosis into a
translator between the analog and the digital, broadening the horizons of
our journey into electronics and interaction.

Figure 8-4. Analog pins of Arduino

Within the realm of electronics, the Analog-to-Digital Converter (ADC)


stands as a transformative sorcerer, weaving spells of translation between
the ethereal realm of analog signals and the digital domain. As a warden of
conversion, the ADC possesses the uncanny ability to metamorphose the
continuum of voltage levels, stretching from 0 to 5 volts, into a regimented
battalion of numbers spanning from 0 to 1023. This numerical orchestra
arises from the ADC’s ten-bit might, as 2 raised to the power of 10 grants
us 1024 possibilities—accounting for the pivotal zero, the ultimate
conductor’s cue.
In our quest to understand this alchemical transformation, we embark
on the construction of a circuit—a bridge between the tangible and the
digital. At its heart lies a trusty LED, its luminescent story unchanged
from the preceding chapter. However, this time, the dance partner is a

139
Chapter 8 Arduino Input Basics

potentiometer—an enigmatic three-legged entity. The potentiometer’s


extremities, steadfast in their resistance, lay the foundation for variation.
Between them, the middle leg—the wiper—sweeps across the spectrum of
resistance, forging a link between the digital world and the analog realm.
This wiper, akin to a conductor’s baton, is summoned to interface with
Arduino’s analog pin A0—a gateway to the digital cosmos. Its companions,
one tethered to VCC and the other to ground, furnish the potentiometer
with power, thus establishing a realm where resistance becomes malleable.
As the circuit takes shape, the wiper—a conductor of change—is clothed
in verdant green, a visual reminder of its transformative role. With the
potentiometer’s knob rotation, the wiper embarks on a journey of resistance
alteration, effectively morphing the analog value it presents to Arduino.
In this intricate ballet, each rotation becomes a dialogue—a whisper
from the physical world translated into the digital lexicon of numbers. The
potentiometer, through its variable resistance, bestows upon us the gift of
analog change. With each turn, the analog value oscillates—a signal that
cascades into the depths of Arduino’s circuitry.
Through this interaction, we unveil the heart of analog-digital
interplay—a symphony where the real and the digital meet and converse.
With each knob’s twist, we orchestrate a unique sequence of numerical
pulses—a testament to the ADC’s role as the conduit of translation. This
dance, where knobs become code and resistance becomes value, is a ballet
that spans dimensions.
As the potentiometer’s knob yields to touch, we witness the tapestry of
transformation. The dance of resistance finds its digital counterpart in the
shifting landscape of analog values. In this narrative, the potentiometer
becomes a maestro, dictating the rhythm of interaction—one that elegantly
weaves together the physical and the digital.
In conclusion, the ADC’s alchemy takes center stage as it converts
the nuances of analog voltage into a digital realm of numbers. Our
circuit, featuring the LED and the potentiometer, becomes a stage for this
transformation—a convergence of analog and digital interaction. This

140
Chapter 8 Arduino Input Basics

interplay, where resistance becomes a canvas for value, offers a glimpse


into the artistry of electronics—a tale that spans voltage ranges and
numerical arrays.

Figure 8-5. Connecting fixed legs of potentiometer to power rail and


wiper to analog pin of Arduino

Embarking on a journey through the realm of code, we now find


ourselves poised at the threshold of the coding area. Here, the language
of instruction and interaction unfolds, enabling us to breathe life into
our digital canvas. As we delve into the coding nuances, the stage is set to
sculpt interactions and unveil the hidden potential of our potentiometer-­
led duet.
In our quest for streamlined precision, we turn our attention to the
“clothing” section—a repository of commands that will sculpt our code
into a functional masterpiece. With deft motions, the extraneous elements
fall away, leaving only the lead command—a sentinel of illumination that
awaits our orchestration.

141
Chapter 8 Arduino Input Basics

A pivotal transformation beckons as we traverse toward the “variables”


section—an enclave that breathes life into data manipulation. Here, amidst
the digital enigma, we create a sanctuary for knowledge—a haven for the
sensorValue variable. This variable, the keeper of potentiometer’s state,
stands ready to encapsulate the analog essence.
With the stage set, the “set” block emerges as the harbinger of
transformation—a bridge between the analog world and the digital
realm. We turn our gaze to the “input” domain, where we pluck the “set”
block and position it upon our digital canvas. This block, the catalyst
for interaction, bears the responsibility of reading the potentiometer’s
whispers.
The ritual of command assembly commences—a ritual where
variables are woven into the fabric of interaction. Within the “set” block’s
parameters, the sensorValue variable finds its purpose—a vessel to capture
the potentiometer’s state. The analog pin A0, a conduit of analog potential,
is assigned as the value that sensorValue shall cradle.
As the LED is beckoned to life, the digital meets the analog in a sublime
dance of luminosity. The very essence of analog value now serves as the
maestro—a guide for the LED’s cadence. This analog value, a storyteller
of potentiometer’s inclination, becomes the pivot upon which the LED’s
illumination pivots.
The mastery of interaction is further enhanced as we harness the
analog value’s potency—a key that unlocks the LED’s radiant embrace.
This interaction, a testament to the digital’s ability to translate analog
whispers into tangible brilliance, becomes a tale of harmony and
illumination.
In this symphony of code, the potency of analog value is unveiled—a
gateway that bridges the abstract with the tangible, the analog with the
digital. Through this dance, we transform the mere on-and-off of an LED
into a narrative of interaction, a dialogue between the potentiometer’s
state and the LED’s luminosity.

142
Chapter 8 Arduino Input Basics

In conclusion, the act of translating analog value into digital action


showcases the Arduino’s remarkable ability to bridge the gap between
the analog and digital realms. As we orchestrate the LED’s illumination
through the whispers of the potentiometer, we create a nuanced
interplay—an interaction that resonates beyond mere code. This journey
into coding’s depths underscores the Arduino’s prowess as a conduit of
intention, turning analog potential into a canvas of digital brilliance.

Figure 8-6. Code block to read analog value and to control the delay
accordingly

In the realm of Arduino exploration, our journey continues as we


navigate the landscape of analog inputs and outputs. This chapter unveils
the art of harnessing the analog potential of the Arduino to interact with
the physical world. Through a captivating dance of code and interaction,
we shall learn to read analog inputs from the analog pins, using this data to
perform various tasks and craft dynamic applications.
As we begin this exploration, our gaze falls upon the input category,
a realm brimming with possibilities. Within its depths lies a treasure—a
block aptly named “read analog pin.” With a swift motion, we summon
this block into our digital realm, a beacon of connectivity between the

143
Chapter 8 Arduino Input Basics

physical and the virtual. As this block emerges, a conduit is created—a


channel through which the Arduino can commune with analog signals in
the physical world.
In parallel, the output category presents itself, and from its midst, we
pluck the foundational block that governs the built-in LED. This block
becomes a beacon of our digital canvas, a point of interaction where data
will manifest as tangible illumination.
But what bridges the gap between these interactions? The control
category answers this call with the “wait” block—a master of temporal
orchestration. With its guidance, we create pauses in our program,
allowing the Arduino to navigate the passage of time and embrace the
rhythm of the physical world.
And now, the heart of the matter—the variables. The “sensorValue,”
our vessel of data, emerges as a protagonist, ready to encapsulate the
analog essence. This value, harvested from the potentiometer’s subtle
nuances, becomes a conduit for interaction, a thread that connects the
physical gesture with the digital interpretation.
But how does this interaction unfold? Our imagination takes flight as we
envision a scenario: the LED, responding to the whispers of the sensorValue.
The “wait” block, rather than operating on a fixed schedule, bends to the
will of the potentiometer knob. The sensorValue, as dynamic as human
intention, becomes the maestro, dictating the tempo of illumination.
In this symphony, the LED blinks in harmony with the potentiometer’s
whims. A twist to the right, and the LED’s rhythm quickens—a dance
of light that resonates with excitement. A turn to the left, and the LED’s
cadence mellows—a tranquil interplay of luminosity. The sensorValue, a
translator of tactile intention, weaves a narrative that dances beyond the
confines of code.
In the realm of simulation, our efforts come to life. The LED, a living
entity, pulses with vibrancy—its pace a mirror to the potentiometer’s
touch. The knob’s journey from one extreme to another paints a picture of
interactivity—a union of analog and digital, tangible and virtual.

144
Chapter 8 Arduino Input Basics

This ability to glean insights from analog inputs is a cornerstone of


Arduino’s prowess. It empowers us to bridge the gap between the digital
and physical worlds, shaping the environment according to our intentions.
This skill finds its footing in an array of applications:
Sensor Monitoring: The Arduino, with its knack for reading analog
inputs, becomes a guardian of sensors. Temperature, light, pressure—
these sensors yield data that the Arduino interprets, empowering it to
control devices or sound alarms in response.
Control Systems: Precision finds a home in the Arduino’s ability to read
analog inputs. Motors, pumps, intricate mechanical systems—all benefit
from real-­time adjustments based on analog data, becoming instruments
of orchestrated movement.
Data Acquisition: The Arduino, an adept data gatherer, reads analog
inputs to collect environmental data. Weather information, environmental
conditions—this data can be channeled to computers or cloud services for
further analysis and decision-making.
In conclusion, this chapter illuminates the fusion of code and
interaction, demonstrating how the Arduino’s analog capabilities empower
us to interact with the world in myriad ways. By embracing analog inputs,
we unlock a realm of interactivity that bridges the gap between the digital
and the tangible. This journey into the heart of Arduino’s analog prowess
unveils its potential to mold the physical world according to our creative
intention—a skill that resonates across applications and industries.

145
CHAPTER 9

Dealing with RGB LED


with Potentiometers
The canvas of our exploration expands, unveiling a realm where creativity
and technology converge in a mesmerizing dance of light and color
manipulation. Within this chapter’s narrative, we shall delve into the art
of crafting diverse lighting effects by wielding the power of RGB LEDs in
harmony with the Arduino platform.
RGB LEDs, those remarkable Red-Green-Blue Light-Emitting Diodes,
stand as the protagonists of our digital saga. These electronic wonders
possess the uncanny ability to produce a rich spectrum of colors by
orchestrating the primary hues of red, green, and blue. Their versatility has
found a home in a plethora of applications, spanning from illumination
and visual displays to signage and decorative installations. Comprising
three individual diodes, each tinted with its own primary color, RGB LEDs
pave the way for an artist’s palette of light.
The magic begins when the intensity of each diode is tailored to create
an intricate dance of colors. This dance, whether dynamic or static, comes
to life through a symphony of voltage modulation. By interfacing these
luminous wonders with the Arduino, we embark on a journey of creative
potential, where colors are not merely chosen, but sculpted.
Our journey commences with the orchestration of a circuit, a virtual
creation brought to life in the realm of Tinkercad. The stage is set with an
Arduino Uno and a breadboard, their digital veins intertwined to form a

© Ashraf Said Ahmad AlMadhoun 2023 147


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_9
Chapter 9 Dealing with RGB LED with Potentiometers

conduit of power. Here, an RGB LED takes center stage, accompanied by


the loyal company of three resistors. As if embodying a trinity of light, the
RGB LED’s four pins—three anodes and one cathode—stand poised to
transform electrical impulses into vibrant illumination.
The symbiotic relationship between colors and pins unfolds as each
primary color—red, green, and blue—finds a home in one of the RGB
LED’s anodes. Like painters of light, these color pins are connected to
Arduino’s digital output pins, accompanied by vigilant 220-ohm current-­
limiting resistors. With this arrangement, pulse width modulation (PWM)
emerges as the conductor’s baton, enabling us to manipulate the voltage
applied to each pin. This modulation, an art form in itself, is the key to
birthing various hues from the RGB LED’s diodes.
A vivid tableau springs forth in Figure 9-1, a visual representation of
our digital symphony. As the RGB LED’s color pins align with Arduino’s
digital pins 9, 10, and 11, a synchronized ballet of current and code ensues.
The 220-ohm resistors, guardians of luminosity, march in unison, ensuring
a harmonious balance between voltage and diode brilliance. The cathode,
grounded and unwavering, stands as the foundation of our luminous
creation.

Figure 9-1. Connect RGB LED with PWM pins of Arduino

148
Chapter 9 Dealing with RGB LED with Potentiometers

This stage, set in the realm of the virtual, serves as the canvas upon
which our illumination masterpiece shall be painted. Through the
interplay of color pins, resistors, and Arduino’s prowess, a new narrative
unfolds—one where colors transcend their ordinary boundaries, where
technology becomes the brush, and where creativity paints the canvas
of light.
In closing, the world of RGB LEDs and Arduino beckons us into a realm
of limitless potential. Through this harmonious partnership, we become
creators of illumination, crafting a symphony of colors that transcends the
ordinary. The circuit, a portal between imagination and reality, offers a
playground for exploration. As we navigate from connections to code, we
journey into a domain where light becomes our medium and colors our
brushstrokes—a tale of innovation, transformation, and the boundless
fusion of creativity and technology.
In the realm of creative coding and luminous expression, we find
ourselves ready to craft our own symphony of light. As our journey unfolds,
we step into the world of code creation, guided by the pulsating heart of
our RGB LED. Let us embark upon this journey, selecting blocks from our
digital arsenal to orchestrate a harmonious dance of colors and brightness.
With eager anticipation, our gaze falls upon the block window—a
treasure trove of possibilities. Within its confines, we find the tools to shape
light, to breathe life into our LED canvas. Among the offerings, we discern
the RGB LED block—an ambassador of illumination. With a deft hand, we
pluck this block from the window and place it upon our digital canvas, as
depicted in Figure 9-2.

149
Chapter 9 Dealing with RGB LED with Potentiometers

Figure 9-2. Set the brightness of RGB LED

With the RGB LED block on our virtual stage, a choice presents itself—
the selection of pins to which the colors of our LED are tethered. This
decision, akin to selecting a palette, defines the avenues through which
light will flow. Figure 9-2 serves as our guide, demonstrating the selection
of pins 9, 10, and 11—a trinity of possibility that beckons us to unveil the
RGB LED’s true potential.
As our brush meets canvas, a new dimension unfurls—a palette
of colors bathed in a gradient of luminosity. In Figure 9-3, a color bar
emerges—an embodiment of choice and expression. With a simple
click, a world of hues unfolds before us. By selecting a hue—let’s say
the passionate embrace of red—we set the stage for a captivating
transformation. The RGB LED, ever obedient to our commands, responds
by adjusting the brightness of each LED diode, crafting a symphony of
crimson luminosity.

150
Chapter 9 Dealing with RGB LED with Potentiometers

Figure 9-3. Selecting color from the color bar

The culmination of our creative endeavor comes to fruition


in Figure 9-4. Here, the LED, once radiant with red, undergoes a
metamorphosis into a new hue—a testament to the fluidity of artistic
expression through code. With the ease of selecting a color, we have
painted our digital canvas anew, and in this transformation, we find a
reflection of our creative spirit.

Figure 9-4. Change the color of RGB LED

151
Chapter 9 Dealing with RGB LED with Potentiometers

In this journey, the blocks become our tools, the canvas becomes
our LED, and code becomes our artistry. The process of selection and
arrangement, guided by the intuitive interface, transforms the abstract into
the tangible. Through a sequence of clicks and choices, we have witnessed
the dawn of a new era—an era where colors and light intertwine, where
creativity and technology converge in a symphony of vibrant illumination.
In conclusion, the narrative woven through the process of code
selection and execution showcases the remarkable synergy between
creativity and technology. The blocks, those building blocks of expression,
empower us to transform the mundane into the extraordinary. The LED, a
canvas of light, becomes an instrument of our imagination. As we journey
from selection to execution, we unveil a tapestry where the virtual and the
tangible intersect—an artful dance where code illuminates our vision.
Within the realm of Figure 9-5, a textual tableau unfolds, revealing the
inner workings of a symphony of light and shadow, guided by the subtle
nuances of PWM (Pulse Width Modulation). This narrative beckons us
to embark on an exploration of how the brightness of our LED can be
harnessed and manipulated to paint an enchanting canvas of luminosity.
As the curtain rises, we are greeted by the resonance of the PWM pins
of our Arduino—three digital emissaries designated to partake in the art
of illumination. These pins, adorned in the role of outputs, stand ready to
transmit the painterly strokes of analog voltages that will transform our
LED’s brilliance.
The maestro of this luminous opera is the “analogWrite” command—
an instrument through which Arduino weaves its magic. This command,
akin to a conductor’s baton, orchestrates the transmission of PWM signals
to the designated output pins. These PWM signals, reminiscent of ethereal
waves, carry values that stretch along a spectrum from 0 to 255—a familiar
territory discussed in earlier chapters.

152
Chapter 9 Dealing with RGB LED with Potentiometers

In this spectrum, each value is a unique brushstroke, an artistic


interpretation of intensity. As the command beckons, a dance of voltages
commences, delicately modulating the width of the pulses, thereby altering
the brightness of our LED. This modulation encapsulates the very essence of
artistic expression—a gradation from dark to light, from subtle to intense.
The canvas that unfurls is not a static one, but a tapestry of infinite
potential. By selecting values within this 0-to-255 range, a world of
possibilities opens. Each value crafts a distinct lighting effect—a story of
luminosity that resonates with the human touch. The lower values cloak
the LED in a gentle glow, a whisper of radiance. As values ascend, the
LED’s brilliance swells, casting a radiant glow that bathes the surroundings
in an aura of light.
In this symphony of values, the LED transcends its binary nature,
evolving into an instrument of emotion and ambiance. It becomes a
storyteller, whispering narratives of brightness, creating moods that
resonate with the creator’s intention. The analogWrite command, a
sorcerer’s wand, not only conjures light but transforms it into an entity that
communicates, evokes, and enchants.
In conclusion, Figure 9-5’s textual tableau opens a window into the
realm of creative illumination. Through the manipulation of PWM signals,
a language of light emerges—a language that speaks to the artist’s soul.
The PWM pins, the conduits of artistic intent, wield the power to translate
numerical values into an ever-changing spectrum of luminosity. This
exploration redefines the LED as more than a mere component—it is an
instrument of expression, a testament to the marriage of technology and
imagination.

153
Chapter 9 Dealing with RGB LED with Potentiometers

Figure 9-5. Text block to adjust RGB LED brightness

In this captivating narrative of control and creativity, a new dimension


unfurls as we relinquish the reins of color manipulation to the gentle touch
of potentiometers. The stage is set for a more tactile experience, one where
the act of varying a knob imparts life to the luminous ballet of the RGB
LED, casting a unique enchantment upon its canvas.
As we transition into this realm of hands-on control, the embodiment
of our intent takes the form of three potentiometers—each a sentinel of
artistic expression. Their strategic placement within the circuit marks a
pivotal juncture, their essence woven into the fabric of Figure 9-6.
These potentiometers, with their fixed ends tethered to the nurturing
embrace of power rails—5V and ground—create a bridge between
potential and reality. The potentiometers’ wipers, guided by human
touch, extend their tactile fingertips to the analog pins of the Arduino.
This connection, akin to a spiritual bond, renders the potentiometers as
interpreters of intention, translating the fluid motions of human fingers
into tangible analog signals.
In this tactile symphony, each potentiometer embraces a diode of the RGB
LED, poised to bestow upon it a unique aura of brightness. The act of varying
the knob, once an action of subtle manipulation, now becomes an instrument
of artistic expression. A delicate turn sets in motion a wave of change, a
transformation that infuses the LED with varying degrees of luminosity.

154
Chapter 9 Dealing with RGB LED with Potentiometers

The result is a collective masterpiece—a tableau of light and color


where each diode dances with its own intensity, weaving a visual tapestry
that transcends binary existence. The potentiometers, though diminutive
in size, wield immense power, allowing individuals to paint with light and
dance with hues, creating a symphony of illumination that resonates with
the artist’s touch.
In this narrative, the potentiometers emerge as conduits between
the ethereal and the corporeal. Their tactile embrace bridges the gap
between intention and execution, allowing mere mortals to sculpt light
and craft color. The dance of technology and artistry transforms the simple
act of knob-turning into a voyage of discovery, where innovation and
imagination meld seamlessly.
In conclusion, the integration of potentiometers into the RGB LED
landscape opens a realm of infinite possibility. Through the touch of a
finger, a new dimension of artistic expression is unlocked—a realm where
illumination is a canvas and color is the brushstroke. Figure 9-6 serves
as a visual testament to this synergy, a moment frozen in time where
technology and creativity meld to create a luminous narrative that is both
captivating and personal.

Figure 9-6. Connect potentiometers to analog pins of Arduino

155
Chapter 9 Dealing with RGB LED with Potentiometers

In this captivating chapter of interaction, we venture forth to imbue


the RGB LED with the hues of our choice, crafting a symphony of colors
through the harmonious dance of potentiometers. Our objective is clear:
we shall orchestrate the convergence of technology and creativity by
harnessing the analog values from three potentiometers to imbue life into
the RGB LED’s vivid canvas.
As our journey unfolds, the ensemble of variables emerges as a
cornerstone. Like attentive scribes, we summon three variables from
the ethereal realm of code to earthly existence. These digital vessels,
named sensorValue1, sensorValue2, and sensorValue3, stand poised to
encapsulate the analog values emanating from the trio of potentiometers.
With variables at the ready, the stage is set for the grand entry of the “set”
blocks, each bearing the promise of aligning the variables with their analog
counterparts. These blocks, like diligent messengers, facilitate the seamless
transmission of data. With precision akin to a maestro’s conducting,
we bestow the honor of capturing sensor values upon sensorValue1,
sensorValue2, and sensorValue3 through their designated “set” blocks.
The saga continues with the “read analog pin” block, a sentinel of
interactivity that liaises between the digital realm and the tactile touch of
human hands. This block, when summoned from the repository of input
components, unfurls its abilities by bridging the gap between code and
the potentiometers. With nimble fingers, we allocate A0, A1, and A2 to
serve as conduits for the analog values of sensorValue1, sensorValue2, and
sensorValue3, respectively, as elegantly portrayed in the visual tapestry of
Figure 9-7.
In this intricate ballet, each element plays its part. The variables,
like guardians of data, nurture the numerical essence of analog signals.
The “set” blocks, obedient to their programming, channel this data into
the realm of code. The “read analog pin” block, a bridge spanning two
worlds, communes with the potentiometers to retrieve their analog
interpretations.

156
Chapter 9 Dealing with RGB LED with Potentiometers

In summary, the symphony commences, harmonizing the ethereal


with the tangible, the digital with the sensory. With potentiometers as
our muses and code as our conductor, we embark on a journey where
the hues of the RGB LED become an extension of our creativity. The
potentiometers, guided by human touch, guide the analog values. The
variables, those digital sentinels, house the soul of the data. And as the
“set” and “read analog pin” blocks come together, a poetic exchange
unfolds, giving life to a tale where technology and artistry coalesce in a
dance of colors that resonate beyond the boundaries of the screen.

Figure 9-7. Block Coding: Using blocks instead of writing lines of code

What unfolds within this intricate tapestry of code and interaction is a


masterful choreography of data and light, where each step and command
contributes to an orchestrated symphony of visual display. In the realm
of Figure 9-8, the code’s elegance comes to life as it guides us through the
dance of the potentiometers and RGB LED.
As the narrative continues to unfold, the intricacies of the process are
revealed. It’s as if the code has become a storyteller, weaving together the
movements of analog values and the luminous response of the RGB LED. It
begins with the first potentiometer, the sentinel of A0, where sensorValue1

157
Chapter 9 Dealing with RGB LED with Potentiometers

is conceived. With a gracious gesture, this value is transmitted to the red


leg of the LED, found at pin 11. The LED responds, painting the canvas
with a hue corresponding to the sensorValue1.
The tale then transitions to the second protagonist, the potentiometer
overseeing A1. Its role is equally crucial, culminating in the birth of
sensorValue2. This value, a sentinel of green luminosity, journeys forth
to find its purpose at pin 9, the green haven of the RGB LED. Here, light
intertwines with data, giving birth to shades that transcend the binary world.
The third potentiometer enters the stage, following the footsteps of
its counterparts. A0 and A1 have paved the way, and now it is A2’s turn.
Its analog value is cast into the limelight as sensorValue3. Guided by
the code’s instructions, this value embarks on a transformative journey,
illuminating the RGB LED’s blue domain at pin 10.
The culmination of this intricate ballet unfolds within the realm of
simulation. Figure 9-8, a window into this ballet’s performance, captures
moments frozen in time. The positions of the potentiometer knobs, each
a fingerprint of human interaction, are preserved for inspection. The RGB
LED, a silent protagonist in this narrative, dons varying robes of light.
The display is a testament to the harmony achieved between code and
hardware.
In the following acts, Figures 9-9, 9-10, and 9-11 cast primary colors—
green, blue, and red—into the spotlight. These colors, the building blocks
of a vibrant spectrum, become the canvas upon which potentiometer
manipulation paints vivid tales. With knobs strategically positioned,
each potentiometer unfurls a specific hue upon the RGB LED, invoking
emotions and memories that colors evoke.
In this symphony of interaction, the code assumes the role of a
conductor, orchestrating the harmony between sensor values and color
presentation. The potentiometers, those humble interpreters of human
intention, guide this dance with graceful precision. And the RGB LED, a
willing canvas, absorbs these instructions and emanates light that dances
beyond the bounds of digital existence.

158
Chapter 9 Dealing with RGB LED with Potentiometers

In closing, what emerges from this narrative is a testament to the


fusion of art and technology. The code, a canvas for human intent,
transforms the mundane into the extraordinary. The potentiometers,
symbols of tactile interaction, become conduits for creative expression.
And the RGB LED, a luminary performer, captivates our senses with its
luminous ballet. Through Figures 9-8 to 9-11, a story unfolds—a story of
synergy, creativity, and the boundless potential of the marriage between
code and the tangible world.
Figure 9-11 shows how the primary color, red, can be displayed on RGB
LED, which means by keeping two potentiometers at 0 positions varying
the knob of the red pin potentiometer will result in the display of red color.

Figure 9-8. Varying the knob of potentiometer, different lighting


effects are observed

Figure 9-9. Just vary the respective potentiometer of green light


results in display of green light

159
Chapter 9 Dealing with RGB LED with Potentiometers

Figure 9-10. Just vary the respective potentiometer of blue light


results in display of blue light

Figure 9-11. Just vary the respective potentiometer of red light results
in display of red light

Illustrated in Figure 9-12, the visual representation of the code


materializes the art of orchestrating blocks to orchestrate the luminous
dance of an RGB LED under the watchful guidance of a potentiometer.
This code exudes a harmonious synchronization between virtual elements
and the tangible realm, a symphony orchestrated by meticulous variables
and deliberate commands.
At its inception, the code bestows definition upon three vital
variables. These vessels, named as vessels of analog input, are designed
to encapsulate the analog values emanating from the hallowed trinity of

160
Chapter 9 Dealing with RGB LED with Potentiometers

analog pins: A0, A1, and A2. These pins, like receptive senses, interpret the
nuances of the surrounding environment, capturing analog signals that
ultimately mold the behavior of our RGB LED.
The act of defining pin modes echoes the allocation of roles within
a theatrical ensemble. As the curtain rises, the analog pins, aptly poised
to interpret the world’s subtle language, are cast into roles of humble
observers. Configured as inputs, they await their cues, ready to engage
in a dialogue with the surrounding variables. In contrast, the digital
pins, electrified with potential, assume the roles of protagonists. Cast as
outputs, they bear the responsibility of painting the RGB LED’s canvas with
vivid hues.
In the symphonic crescendo of code execution, analog values emerge
as the conduits of information, flowing into their designated variables.
Each variable becomes a chalice, cradling the essence of the analog
world it represents. The potency of these variables lies in their ability to
encapsulate reality, transforming physical phenomena into digital form.
The “analogWrite” command stands as the conductor’s baton,
orchestrating a choreography of voltages. As the digital pins, numbered 9,
10, and 11, respond to this command, they imbibe the values encapsulated
within the variables. These values serve as instructions, dictating the
intensity of the light each diode emits. The result is an enchanting display
of luminosity, where the RGB LED emerges as a canvas, painted stroke by
stroke with the hues stored within the variables’ depths.
In conclusion, the journey through Figure 9-12 unravels a narrative of
integration. It is a tale where code bridges the realms of the digital and the
analog, and where variables serve as vessels of understanding. The code
weaves a tapestry of communication between pins and LEDs, casting a
spotlight on the potential for artistic expression through technology. It is
within this digital choreography that the RGB LED and the potentiometer
dance in unison, each movement guided by the elegantly orchestrated
sequence of commands and variables.

161
Chapter 9 Dealing with RGB LED with Potentiometers

Figure 9-12. Text Window to control RGB brightness by using


potentiometers

162
CHAPTER 10

Arduino Serial Monitor


A serial monitor, a cornerstone tool within the Arduino Integrated
Development Environment (IDE), emerges as an indispensable asset in
the realm of Arduino programming. This dynamic tool not only serves
as a conduit for debugging but also facilitates vital communication with
the Arduino board itself. The profound impact of the serial monitor
becomes especially apparent when considering its ability to grant us
real-time access to the stream of data exchanged between the Arduino
and its environment. This real-time insight stands as a formidable aid in
untangling the intricate threads of code-related challenges and anomalies.
The beauty of the serial monitor lies in its dual nature. It is both a
window into the inner workings of the program and a mechanism to
communicate with the Arduino in a tangible way. By observing the data
transmitted to and from the Arduino, developers and programmers can
embark on a journey of discovery, tracking the flow of information and
scrutinizing its behavior. This level of insight transforms the often cryptic
world of programming into a realm of transparency and comprehension.
One of the most compelling applications of the serial monitor is its
prowess in the realm of troubleshooting. When coding projects encounter
roadblocks, the serial monitor becomes a beacon of light, guiding
developers toward the source of the issue. The capability to observe
the flow of data in real-time enables swift identification of glitches and
anomalies. Thus, what may have seemed like an insurmountable puzzle is
demystified through the lens of the serial monitor’s live feedback.

© Ashraf Said Ahmad AlMadhoun 2023 163


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3_10
Chapter 10 Arduino Serial Monitor

At the heart of this interaction lies the visualization of variable changes.


This becomes especially potent when examining the manipulation of
variables within a circuit, as depicted in Figure 10-1. In this case, a circuit
comprising an Arduino and a potentiometer is presented. The objective
at hand is to translate the knob rotation of the potentiometer into a
discernible display of its resistance on the serial monitor. This engagement
between tangible manipulation and digital visualization exemplifies
the power of the serial monitor as a bridge between the virtual and the
physical.

Figure 10-1. Arduino read the analog value of a potentiometer

In essence, the serial monitor transcends its role as a mere debugging


tool. It evolves into a co-pilot in the intricate journey of Arduino
programming, providing insights, feedback, and clarity at every step. This
synergy between human intuition, physical interaction, and real-time data
feedback showcases the intersection of technology and understanding,
encapsulating the essence of the Arduino ethos: a platform that empowers
creativity and exploration through seamless interaction with the digital
and material realms.

164
Chapter 10 Arduino Serial Monitor

Exploring the intricacies of utilizing the code blocks editor in


conjunction with an Arduino input pin brings us to a captivating endeavor.
Our primary objective is to establish a seamless connection between the
Arduino’s input pin and the subsequent display of resistance values within
the serial monitor window.
The first step in this journey involves employing the code blocks editor
to create a responsive mechanism that listens to the fluctuations of an
Arduino input pin. This input pin becomes the window through which
external information is funneled into our programming environment. As
an embodiment of interactivity, this mechanism heralds a new realm of
possibilities in code manipulation and understanding.
Directing our attention to the serial monitor window, it becomes
apparent that its location in the lower segment of the workspace, as
depicted in Figure 10-2, serves as a crucial interface. This interface
becomes the conduit through which information is relayed from the
programming environment to the user. However, as we initiate the
simulation, an intriguing observation comes to light: an initial lack of
visible output within the serial monitor. This dearth of output serves as an
impetus to delve deeper into the intricacies of the system.
To remedy this situation and bestow visibility upon our endeavor, the
introduction of an essential code block comes into play. Drawing from
the reservoir of output-related blocks, the “print serial monitor” block is
harnessed, as exemplified in Figure 10-2. This block acts as the catalyst
that transforms the latent potential of our program into tangible output,
ready for observation and analysis.

165
Chapter 10 Arduino Serial Monitor

Figure 10-2. In the bottom, the tab of serial monitor is shown

Figure 10-3. Block to print on serial monitor

166
Chapter 10 Arduino Serial Monitor

With the strategic placement of the “print serial monitor” block, our
simulation embarks on a new phase. Upon initiating the simulation, a
transformation unfolds within the serial monitor window. What was once
a static “hello world” metamorphoses into a dynamic tapestry of data.
Each iteration of the simulation presents an opportunity to witness the
responsive interaction between the Arduino input pin and the subsequent
display of resistance values.
In essence, this immersive experience encapsulates the dynamic
interplay between hardware and software. The code, a manifestation of
logic and instructions, synergizes with the physical world through the
input pin. The ensuing visual feedback, projected onto the serial monitor
window, completes the circuit of interaction, transforming the virtual into
the tangible.
This exploration not only enriches our understanding of code
execution and hardware integration but also highlights the role of visual
aids in comprehending complex systems. The serial monitor, once a silent
observer, becomes a vital medium of communication, bridging the gap
between the abstract and the concrete.
In conclusion, the journey to extract resistance values from an Arduino
input pin and display them within the serial monitor window is an
exhilarating odyssey. The symbiotic dance between input and output, the
orchestration of code blocks, and the transformation of virtual interactions
into real-world observations collectively compose a symphony of
technological exploration. This journey underscores the potential of
interactive learning environments to nurture a profound understanding of
coding, electronics, and their harmonious fusion.
To elaborate further on this topic, let’s delve into the process of
incorporating the analog potentiometer value into the code and visualizing
its effects through the serial monitor. In order to achieve this, we introduce
a novel variable known as “sensor value” within the code block. This
variable becomes the conduit through which the analog potentiometer’s
value is transmitted and subsequently displayed.

167
Chapter 10 Arduino Serial Monitor

Taking a step-by-step approach, we begin by seamlessly integrating


the “set sensor value” block into the workspace. This foundational step
establishes the connection between the analog potentiometer and the
code’s logic. Next, the variable “sensor value” is seamlessly integrated into
the code, serving as the bridge that links the measured analog input to the
ensuing output.
With the groundwork laid, the previously static “hello world” output
within the “print to serial monitor” block now metamorphoses into
a dynamic representation of the analog potentiometer’s value. This
transformation is illustrated in Figure 10-4, where the amalgamation of the
“sensor value” variable and the “print to serial monitor” block showcases a
new dimension of interactivity. The serial monitor then becomes a canvas
upon which the changing ADC (Analog-to-Digital Converter) values of the
potentiometer are painted.
In the immersive environment of simulation, as the potentiometer’s
knob is manipulated toward both extremes, a symphony of changing
values unfolds. The ADC value, which ranges from 0 to 1023 due to the
inherent 10-bit resolution, is unveiled in Figures 10-5, 10-6, and 10-7.
These graphical representations elegantly capture the transition of the
potentiometer’s state and its corresponding ADC value, thus providing a
tangible visualization of the underlying mechanics.
Remarkably, this simulation also underscores a valuable insight: the
ADC value’s upper limit is indeed 1023, reaffirming the precision of the
­10-­bit ADC resolution. This observation reaffirms the technical aspect of
the system, bolstering the reader’s understanding of the inner workings.

168
Chapter 10 Arduino Serial Monitor

Figure 10-4. Define variable to print its value on serial monitor

Interestingly, Figure 10-7 introduces a novel facet into the


narrative. The duplication of the “print to serial monitor” block, with its
accompanying alteration of content to “000000,” showcases a concept that
extends beyond the confines of mere programming. This technique, akin
to commenting, offers a concise yet effective method of communicating
insights to other programmers or readers. By appending descriptive text,
the output is endowed with context, thus acting as an interpretive layer
that enriches the reader’s comprehension.
In summary, the journey from the analog potentiometer’s value to
its manifestation on the serial monitor is a multifaceted expedition. The
integration of the “sensor value” variable, the dynamic transformation
of the output block, and the captivating visualization of changing ADC
values through figures all contribute to an enriched understanding of the
interplay between hardware and code. This holistic exploration serves
as a testament to the power of interactive learning and underscores
the versatility of programming as a medium of expression and
communication.

169
Chapter 10 Arduino Serial Monitor

Figure 10-5. As potentiometer is at zero position, the serial monitor


is showing 0 value

Figure 10-6. Serial monitor is showing ADC value of potentiometer


w.r.t the current positon of knob

170
Chapter 10 Arduino Serial Monitor

Figure 10-7. Potentiometer knob is at maximum value, serial is


showing maximum value of ADC, as well as 000000 is printed on
serial monitor

 onclusion: Navigating the Circuit


C
Design Odyssey
Our voyage through the captivating world of circuit design and simulation
comes to a close, but it’s not an end; it’s a new beginning. The odyssey
we’ve embarked upon has not only equipped us with practical skills but
also ignited a spark of creativity and innovation that will continue to
illuminate our path in the realm of electronics.
In this book, we’ve explored the intricacies of circuitry, from the
humble resistor’s role in controlling current to the complex interplay
of digital logic gates that drive modern technology. But our journey
doesn’t end with understanding the theory; it extends into the realm
of real-world applications where our newfound knowledge can spark
transformative change.
The beauty of circuit design lies in its versatility and applicability
across a multitude of industries. Imagine breathing life into a robotic arm
that performs intricate surgical procedures with precision, powered by

171
Chapter 10 Arduino Serial Monitor

the very circuits you’ve come to master. Visualize autonomous vehicles


navigating bustling streets, interpreting sensor data to make split-second
decisions, thanks to the foundation of circuit design principles.
Consider renewable energy systems harnessing the power of
the sun and wind, converting photons and air currents into usable
electricity through circuits you’ve designed. Envision smart homes
responding intuitively to occupants’ needs, illuminating rooms, adjusting
temperatures, and securing premises, all orchestrated by the circuits
you’ve learned to craft.
But the impact of circuit design isn’t limited to grand innovations
alone; it extends to everyday conveniences. The smartphone that connects
us to the world relies on intricately designed circuits that transmit signals
and process data. The touch-sensitive interface we interact with daily
hinges on capacitive sensors you now comprehend. Even the LED lights
that brighten our lives owe their luminance to the pulse width modulation
concepts you’ve grasped.
As you venture into the world beyond these pages, remember that
your journey is boundless. Apply your circuit design prowess to hobbies,
unleashing your imagination to create LED art installations that dance
to music or crafting wearable gadgets that meld technology with fashion.
Prototype and iterate on your ideas, knowing that circuit simulation offers
a playground where mistakes are stepping stones to excellence.
Collaboration and community play vital roles in this realm. Engage
with fellow enthusiasts, join maker spaces, and participate in hackathons
to exchange ideas and perspectives. Share your journey on online
platforms, inspiring others and gaining insights that foster growth.
This book has merely been a gateway, a key to unlocking a universe
of creativity and innovation. The circuits you design today could
revolutionize industries tomorrow, and the concepts you’ve grasped will
continue to evolve with technology’s rapid pace.

172
Chapter 10 Arduino Serial Monitor

In closing, embrace circuit design and simulation as tools that


empower you to reshape the world. Cherish the thrill of creation, the
wonder of innovation, and the satisfaction of bringing ideas to life.
Continue to learn, experiment, and stretch your limits, for the world of
electronics beckons, waiting for your unique imprint.
As you journey forth, remember that every circuit has a story to tell,
every connection has a purpose, and every innovation has the potential
to shape a brighter, more electrifying future. The path ahead is rich with
opportunities—embrace them, pioneer them, and let your circuits light the
way. Happy designing!

E xploring Boundless Horizons: Beyond


Circuit Design and Simulation
Congratulations on completing your journey through the captivating world
of circuit design and simulation! Armed with knowledge and practical
skills, you’re now equipped to explore a myriad of exciting possibilities that
extend far beyond the confines of this book’s pages. Here, we unveil the
vast tapestry of opportunities that await you in the realm of electronics and
innovation.
1. Prototyping and Invention:

With circuit design as your foundation, you have the


power to transform your wildest ideas into tangible
prototypes. Whether it’s a smart wearable, a home
automation system, or a novel gadget, you can use
circuit design and simulation tools to bring your
visions to life. Experiment, iterate, and refine your
creations until they reflect your original concept.

173
Chapter 10 Arduino Serial Monitor

2. Electronics Hobbies:

Dive into the realm of electronics hobbies, where


your newfound skills can shine. Explore the intricate
art of building audio amplifiers, designing custom
digital clocks, constructing mini drones, and even
crafting musical instruments. The journey of
building these projects offers both satisfaction and a
continuous learning experience.

3. Robotics and Automation:

Unleash your inner engineer by delving into


robotics and automation. Design and build robotic
systems that can navigate mazes, perform tasks,
or mimic human movements. Combining your
circuitry knowledge with programming skills will
allow you to create robots that interact with their
environment intelligently.

4. Internet of Things (IoT):

Join the revolution of interconnected devices in


the Internet of Things era. Craft smart devices that
communicate with each other and with the cloud.
Monitor your home security system remotely,
control appliances through your smartphone, or
create sensor networks for environmental data
collection—all using your circuit design expertise.

5. Renewable Energy Solutions:

Contribute to sustainable living by designing circuits


that harness renewable energy sources. Construct
solar-­powered chargers for your devices, design

174
Chapter 10 Arduino Serial Monitor

wind turbine control systems, or create energy-


efficient lighting solutions. Your circuits can play
a crucial role in reducing carbon footprints and
promoting eco-friendly practices.
6. Education and Teaching:

Pass on the knowledge you’ve gained by becoming


an educator in electronics and circuitry. Inspire
future generations to explore the world of circuits
through workshops, tutorials, and online courses.
Your ability to simplify complex concepts will make
learning a captivating adventure for others.
7. Entrepreneurship:

Forge your path as an electronics entrepreneur.


Identify gaps in the market and develop innovative
products that solve real-world problems. From
wearable fitness trackers to smart home devices,
your circuit design expertise can lay the foundation
for a successful startup venture.
8. Research and Innovation:
Push the boundaries of knowledge by engaging
in research and innovation. Collaborate with
interdisciplinary teams to develop cutting-edge
technologies that impact fields such as healthcare,
telecommunications, and transportation. Your
circuits could contribute to groundbreaking
discoveries.

175
Chapter 10 Arduino Serial Monitor

9. Open Source Community:

Participate in the vibrant open-source community,


where enthusiasts from around the world
collaborate on projects that range from basic to
highly advanced. Contribute your designs, share
your insights, and benefit from the collective
wisdom of fellow makers and designers.
10. Lifelong Learning:

Remember that the world of electronics is ever-­


evolving. Continue to expand your horizons by
staying updated on the latest technologies, tools,
and methodologies. Explore advanced topics such
as FPGA programming, signal processing, and
wireless communication to further enhance your
skill set.

As you venture into these realms, keep in mind that every challenge
you face is an opportunity to learn and grow. Embrace the process of
experimentation, accept failure as a stepping stone, and celebrate your
successes as milestones of your journey. The path ahead is as diverse as
your imagination, and your circuit design knowledge is the compass that
guides you toward endless exploration and innovation. The world is your
canvas—let your circuits paint the future.

176
Index
A exploration, 143
IDE, 111
Adaptive cruise control, 53
Arduino Analog output, fading
ADC, see Analog-to-digital
LED, 117–127
converter (ADC)
Arduino digital output
Address retrieval and connection, 16
algorithm board, 110
Advanced driver assistance
breadboard, 112
systems (ADAS), 53
circuit, 113
Aerospace and defense, 54
code, 108
Aerospace applications for flight
connect LED with, 108
control, 54
creativity and technology, 115
Agriculture, 55
LED control, 107
Airbag deployment, 53
multiple LEDs and
Air quality, 55
breadboard, 113
Algebraic Logic Unit (ALU),
simulation, 109
17, 27, 29, 30
text for coding, 110
Ammeter, 98, 101, 102
void setup, 114, 115
Analog pins of Arduino, 139, 155
Arduino input basics
Analog-to-digital converter (ADC),
abstract phenomena, 138
138–140, 168
analog input, 137–142, 144
analogWrite command, 125, 126,
circuit’s harmony, 134
153, 161
code blocks, 129
Anti-lock braking systems (ABS), 53
coding with intent and
Arcade machines, 54
purpose, 135
Arduino, 55
intention and execution, 137
analog pins, 154, 155
LED with digital pin, 132
board, 126
mechanical systems, 145
exercises, 128

© Ashraf Said Ahmad AlMadhoun 2023 177


A. S. A. AlMadhoun, Circuit Design and Simulation Quick Start Guide,
Maker Innovations Series, https://doi.org/10.1007/978-1-4842-9582-3
INDEX

Arduino input basics (cont.) Breadboard


physical sensors and digital alphabets/numbers, 88
command, 138 battery, 87
pull-down resistors, 133, 134 full-sized, 87
push button, 135 LED, 112–116
push button’s union with RGB LED, 89
circuitry, 131 with + and–power rails, 87
technological narratives, 130 types, 86
Arduino programming, 77, 163, 164 Brightness, 64, 77, 121
Arduino serial monitor BUS, 18, 20
circuit design odyssey, 171–173 buttonState, 135
resistance values, 167
virtual interactions, 167
Arithmetic logic units (ALUs), 5, 10 C
Artificial Intelligence, 26 Cameras and surveillance
Automation, 9, 10, 23, 25, 51–54, systems, 24
129, 174 Central processing unit (CPU),
Automotive systems, 2, 53 5–7, 9, 13, 14, 19
Avionics, 54 Choreography of arrangement, 79
Circuit
arrangements, 82
B definition, 58
Basic interface, 69 design, 74, 173–176
Battery design odyssey, 171–173
and Breadboard Tango, 78 elements, 79, 95
breadboard, 87 Ensemble, 72
motor, 81 exploration, 78
motor and photo-resistor, 81 simulations, 57, 60
positive and negative Clock circuit for
terminals, 88 synchronization, 5
Biometric authentication Code blocks editor, 165
devices, 55 Code density, 45
Biometrics and security, 55 Coding and circuitry, 77
Bluetooth headphones, 54 Color-coded dance, 78

178
INDEX

Comma-Separated Values (CSV) Data loggers, 24


file, 65, 66 Data manipulation, 27, 30, 46, 66
Communication systems, 54 Data memory, 40
Complete circuit, 80, 94 Data repository and retrieval, 19
Complex Instruction Set Computer Data security, 22
(CISC) architecture for Data sharing, 25
Microcontroller, 42–44 Design and verification
advantages, 45, 46 complexity, 46
hardware complexity and Digital circuits, 133
software efficiency, 46 Digital computing, 8
Component manual, 63–65 Digital ecosystem, 60
Component’s potential, 76 Digital Input, 130, 131, 133
Computational complexity, 4 Digital logic circuits, 133
Computational elegance, 28, 50 Digital logic gates, 171
Computational entity, 6 Digital maestros, 2
Computational power, 4, 31 Digital narratives, 135
Computational symphony, 18 Digital sentinels, 157
Consumer electronics, 53 Digital signal processors (DSPs), 41
Control and monitoring devices, Digital signals, 115, 125, 126
20, 22–24 Digital vessels, 156
Control devices, 21, 23 digitalWrite, 114, 115
Control systems, 145 digitalWrite(LED_BUILTIN,
Crop health, 55 HIGH), 110
Customization, 74 digitalWrite(LED_BUILTIN,
LOW), 110
Distinction, 4, 8, 11, 29, 36
D
Data acquisition, 145
Data and application storage and E
retrieval, 35 EAGLE.BRD format, 63
Data collection, 54, 174 EAGLE software, 61
Data exchange between devices Edge Computing, 26
and applications, 22 Edit Canvas, 70
Data extraction and transmission, 17 Editing components, 71

179
INDEX

Educational Tools, 55 H
Electrical noise, 134
Handheld gaming devices, 54
Electronic metamorphosis, 122
Hardware complexity of CISC
Electronic signals, 73
architectures, 46
Embedded controller, 3, 4
Hardware components, 3, 45
Embedded microcontrollers, 32, 33
Hardware Emphasis, 45
Embedded systems, 41, 53
Harmonizing aesthetics with
Energy management systems, 54
function, 74
Energy utilization, 54
Harvard architecture, 35, 36,
Entertainment and Gaming, 54
39, 40, 42
Entrepreneurship, 175
memory access, 41
Environmental monitoring
predictable timing, 41
devices, 21
Harvard architecture system, 40
Environmental monitoring
Higher-level abstractions, 45
systems, 55
High-stakes systems, 4
Erasable Programmable Read-Only
Home automation, 54, 173
Memory (EPROM), 7
Home monitoring systems, 51
Evolution of microcontroller
technology, 28
Experimentation, 76, 176 I, J, K
Exporting Design in EAGLE.BRD Industrial automation, 9, 21, 53
Format, 62 Informational portal, 62
External memory Information transmission, 18
microcontroller, 34, 35 Infotainment systems, 53
Input/output (I/O) capabilities, 7
F Instruction Decode and
Facial recognition systems, 55 Control Unit, 5
Fading LED, 117–127 Instruction decoding, 14
Fingerprint scanners, 55 Instruction decoding overhead, 46
5G connectivity, 26 Integrated Development
Environment (IDE), 163
Integrated systems, 25
G Integration, 22
Gaming consoles, 54 Intel 8051, 8, 28

180
INDEX

Intel 8086/8088, 5 M
Intel 8096 series, 8, 29, 31, 44
Machine cycle, 14–16
Interconnected
Medical devices, 33, 54
ecosystems, 25
Medical monitors, 24
Internet and exchange data, 53
Memory access modes, 44
Internet of Things
Microchip, 5
(IoT), 22, 53, 174
Microcoding, 45
Interoperability, 25
Microcomputer realm, 7
Intuitive user interfaces, 25
Microcontrollers, 1, 133
analog-to-digital converter
L (ADC), 138
applications, 51–55
Lane departure warning, 53
architectural specifications, 35–37
LED, 59–61, 75–77, 79, 80, 94
architecture, 9
and battery cell, 98
architecture and functionality, 9
and battery, 93, 98
capabilities, 2
binary signals, 117
compact integration, 8
blinking, 136
computational requirements, 8
blinking control, 135
control processes, 8
colors, 74
data processing, 42
complete circuit, 94
digital lives, 2
damage, 93
economic advantage, 8
in ethereal rhythms, 133
8-bit microcontroller, 27, 28
fading, 117, 119–128
embedded systems, 9
modulation, 117
embedding intelligence, 2
performance, 116
energy-efficient
in perpetual brilliance, 137
characteristics, 4
and potentiometer, 140
external memory, 34, 35
and resistor, 95
input/output (I/O) operations, 8
series and parallel circuits,
input/output (I/O) ports, 9
97, 98, 105
instruction execution, 42
tangible entity, 136
vs. microprocessor, 12, 13
Lighting systems, 54
peripherals, 2
Low-power microcontrollers, 41

181
INDEX

Microcontrollers (cont.) Motorola MC68HC12 and


programming, 2 MC68332 families, 29
real-time responsiveness, 4 Motorola’s MC68HC11 series, 28
real-world application, 10 Motor, photo-resistor, and four
resource-efficient solution, 8 battery cells, 83
self-contained control
solution, 7
16-bit microcontroller, 29, 30 N
skillful programming, 2 Navigation systems, 53, 54
specialized entity, 9
specialized processors, 42
32-bit microcontroller, 30–32
O
touchscreens, 53 Ohm’s law, 91–95, 105
types, 26, 27 On-chip resources, 3, 4
user interfaces, 53 One-chip computer, 5
versatility and adaptability, 55 Opcode Lodging in the Instruction
visual articulation, 9 Register, 17
wireless communication, 53
Microprocessors, 2, 5
P, Q
block diagram, 6
Parallel circuits, 97, 100–105
computers, 10
Peripheral hardware, 6
control units, and caches, 10
Personal computing, 10
data processing, 10
Photo-resistor with its slider, 82
laptops, 10
Pollution levels, 55
multitasking, 10
Portal to customization, 73
servers, 10
Potentiometer , 140, 154, 164, 165,
user experiences, 10
167, 168, 170, See also
Modern control and monitoring
RGB LEDs
devices, 22
analog pins, 155
Moment of activation, 76
analog values, 156
Monitoring devices, 21, 22, 24–26
blue light, 160
Motor controllers, 23
commands and variables, 161
Motorola M683xx and Intel/Atmel
green light, 159
251 families, 31

182
INDEX

lighting effects, 159 Red-Green-Blue (RGB) Light-


power rails, 154 Emitting Diodes,147, See
red light, 160 RGB LEDs
sensorValue1, 157 Reduced Instruction Set Computer
sensorValue2, 158 (RISC) architecture for
symphony of illumination, 155 microcontroller, 47–49
Power consumption, 4, 9, 46, 52 Reduced Instruction Set Computer
Power management, 53 (RISC) architectures, 44, 50
Precision agriculture for Reduced memory footprint, 45
monitoring soil Remote controls, 25, 54
conditions, 55 Renewable energy systems, 54,
Princeton architecture, 35 172, 174
Print serial monitor block, 166–168 Resistance
Processing-intensive brightness, 77
microprocessor properties, 74, 76
instruction, 12 sensor, 81
Program Counter (PC), 5, 16, 17 Resistor and LED, 95
Programmable Logic Controllers Resistor’s enigmatic role, 77
(PLCs), 21, 23 Resistor’s prelude, 72
Programmable Read-Only Memory Resource management, 3
(PROM), 7 Resource usage and enhance crop
Program memory, 34, 40 yield, 55
Pulse width modulation (PWM), Retinal scanners, 55
126, 127, 148, 149, 152, 153 RGB LEDs
analog pins of Arduino, 156
anticipation, 149
R Arduino beckons, 149
Radar systems, 54 artistic expression, 151
Random Access Memory (RAM), brightness, 150, 154
7, 16, 38 circuit, 90
Raspberry Pi, 55 color bar, 151
Read activation, 16 digital vessels, 156
Read-Only Memory (ROM), 7 luminary performer, 159
READ Operation, 19 luminosity, 153

183
INDEX

RGB LEDs (cont.) electronics and


pin modes, 161 innovation, 173–176
potentiometers, 154, 155 print serial monitor, 165,
PWM pins, 152 166, 168
with PWM pins, 149 step-by-step approach, 168
read analog pin, 156, 157 troubleshooting, 163
resistor on breadboard, 89 variable definition, 169
selection and arrangement, 152 visualization, 164
Text Window, 162 window, 165
transformation, 150 Series circuits, 97–99, 101, 103, 104
value crafts, 153 Simulated circuit landscape, 59
versatility, 147 Simulation process, 57, 59, 76
visual representation, 160 Smart locks, 54
Rich Instruction Set, 45 Solar inverters, 54
Robotics, 52 Specific Instruction Set Computer
RPM, 82 (SISC) architecture for
microcontroller, 50, 51
Symbiosis, 11
S Symphony of visual display, 157
Satellite communication, 54
Security cameras, 54
Sensor monitoring, 145 T
Sensors, 24 Thermostats, 10, 23, 53
sensorValue3, 156, 158 Tinkercad
Separate memory spaces, 40 circuit, 58, 59
Serial monitor , 163, See also circuit simulation
Arduino serial monitor capabilities, 57
circuit design and library icon, 111
simulation, 173–176 Traditional computing, 4
code blocks editor, 165 Traffic light system, 72
debugging tool, 164
developers and
programmers, 163 U
dual nature, 163 Usability, 25

184
INDEX

V Von Neumann-based
microcontrollers, 37–39
Variable Frequency Drives
(VFDs), 23
Variable-Length Instructions, W, X, Y, Z
CISC, 45
Water quality, 55
VCRs, 10, 51
Wearable fitness trackers,
Very Large Scale Integration
22, 53, 175
(VLSI) chip, 5
Weather conditions, 55
Virtual design, 80
Weather data, 55
Voice-controlled assistants, 54
Wind turbines, 54
Voltmeter, 98, 102, 103
Wireless speakers, 54
Von Neumann and Harvard
Wiring components, 78
architectures, 36, 37
WRITE operation, 19
Von Neumann architecture, 36,
38, 39, 41

185

You might also like