0% found this document useful (0 votes)
18 views325 pages

Arsath Natheem s - Arduino Book for Beginners _ Getting Started With Arduino and Basic Programming With Projects (New Edition 2022)

The 'Arduino Book for Beginners' by Arsath Natheem S provides a comprehensive guide to Arduino programming and project development, aimed at both novices and experienced users. It covers essential topics such as basic electronics, programming structures, and includes 33 hands-on projects along with over 100 additional project ideas. The book emphasizes practical learning and problem-solving through real-world applications of Arduino technology.

Uploaded by

sarasakthi456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views325 pages

Arsath Natheem s - Arduino Book for Beginners _ Getting Started With Arduino and Basic Programming With Projects (New Edition 2022)

The 'Arduino Book for Beginners' by Arsath Natheem S provides a comprehensive guide to Arduino programming and project development, aimed at both novices and experienced users. It covers essential topics such as basic electronics, programming structures, and includes 33 hands-on projects along with over 100 additional project ideas. The book emphasizes practical learning and problem-solving through real-world applications of Arduino technology.

Uploaded by

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

ARDUINO

BOOK FOR
BEGINNERS
GETTING STARTED WITH ARDUINO BASICS
PROGRAMMING WITH PROJECTS (New Edition 2022)

ARSATH NATHEEM S
Copyright © 2021-2022 by ARSATH NATHEEM S
All rights Reserved.
Author Name: Arsath Natheem S

2022 Edition

This Arduino book is geared towards given that exact and reliable data in
respects to the subject and issue covered. The publication is marketed with
the concept that the publisher is not necessary to render or else, any qualified
services.
In no way is it valid to reproduce, duplicate, or spread any part of this book
in either digital e-format, eBook means or in printed format. Make a Re-
documenting of this text book is strictly prohibited and any storage of this
manuscript is not allowed except with written approval from the publisher.
All rights reserved.
Respective authors own all rights not held by the publisher. The attributes
that are used are without any consent, and the book of the trademark is
without permission or backing by the brand owner. All trademarks and
brands within this book are for descriptive purposes only and are the owned
by the owners themselves, not associated with this textbook.

W HY I W ROTE T HIS B OOK

When we think about the word ‘Education’, we often think of the formal
schooling that happens in primary, secondary and high schools and colleges.
Although, this is not the only way of education, tacit and practical knowledge
is something that we often can’t learn by reading books; it is achieved by
addressing real world problems and practice, it relates to experience,
intuition, ideals, creative thinking, emotions, values, skills and attitudes.
Arduino Education makes the next generation of STEAM programs and tacit
knowledge that empower schoolchildren on their creative learning journey
through secondary school, high school, and university and help them succeed.

Arduino has been used in thousands of unique projects and various


development applications. The Arduino software is simple-to-use
application for beginners, and now flexible enough for advanced users,
teachers and scholars and use it to build cost efficient scientific devices, to
demonstrate chemistry and physics principles, or to get started with
programming and robotics, Project based learning will lead to cooperating
education and create a deeper impact on the student. It also builds the
understanding part more enjoyable as students are able to understand more
while learning it in a group. Consequently, let us focus on a plethora of
simple projects related to Interesting Arduino sensors that will enhance
student’s innovative mindset. The Arduino project works at all times and
makes improvements to the existing system, and for that reason, Ultimately,
students can develop a forward-thinking practical mindset and way of
thinking.

“Tell me and I forget, teach me and I may remember, involve me and I


learn” -- Benjamin Franklin
W HY Y OU S HOULD R EAD T HIS B OOK
This Arduino beginner’s book will help you learn all about making projects
with Arduino, and beneficial for novice to expert level students, and research
scholars. This handbook is written for those who is enthusiastic in innovative
projects with the help of open source tools and technique, and it is a huge
collection of ideas to do some creative projects, to create something new to
society, This book consists of six chapters starting from Arduino basics,
electronic components, Arduino boards and their sensors, to getting started
with Arduino programming, then you can practice 33 step by step projects by
doing, and the book ends with more than 100 fascinating project-ideas and
finally Troubleshooting Arduino. I believe this Arduino handbook will be
helpful for students and research scholars for their mini projects. Also
includes operative basics in case of open-source electronics, for college,
school students and hobbyists to learn Arduino from the basic to expert level
through practical schematic diagrams. I hope this would be a wonderful
project guide for science fair projects and their new innovative works.
TABLE OF CONTENTS
CHAPTER 1:
ARDUINO: EVERYONE NEED TO KNOW
Introduction
Microcontroller
Development Board
What is the Arduino?
Why Was Arduino Developed?
What can Arduino be used to Teach?
DIFFERENT TYPES OF ARDUINOS
Why use Arduino UNO?
GETTING STARTED WITH ARDUINO
Installing Arduino IDE with Arduino Uno R3 board
Arduino Libraries
How to add library files
Hello World of Arduino (Blink an LED):
Basic Arduino C functions:
Uploading the Sketches
Arduino Q & A Section
Summary

CHAPTER 2:
BASIC ELECTRONIC COMPONENTS
Resistors
Capacitors
Inductors
Transformer
Diode
Light emitting diode (LED)
Variable resistor (Potentiometer)
Transistors
Integrated circuit (IC)
IC Terminology: Op-amp
H-bridge
Printed Circuit Board (PCB)
WHAT ARE SOME GOOD COMPONENTS TO START WITH?
LED (Light Emitting Diode)
LCD (Liquid Crystal Display)
DC Motor
Servo Motor
Stepper Motor
LIST OF ARDUINO SENSORS AND MODULES
Ultrasonic Sensor Module
IR Infrared Obstacle Avoidance Sensor Module
IR Infrared Fire/Flame Detection sensor
Soil Hygrometer Detection or Soil Moisture Sensor
Humidity and Rain Detection Sensor
Microphone Sensor or Sound Sensor
Digital Barometric Pressure Sensor
Photoresistor Sensor (LDR)
Digital Thermal Sensor - Humidity Sensor
DHT11 Temperature and Humidity Sensor
Rotary Encoder Module
SW-420 Motion Sensor or Vibration Sensor
Passive Buzzer Module
Speed Sensor Module LM393
Relay Module
HC- SR501 Pyroelectric Infrared Sensor (PIR)
Accelerometer Module
Arduino Joystick Module
Piezo buzzer Sensor
Water Flow Sensor
Arduino Color Sensor
Optical Fingerprint Sensor
Heart Rate or Pulse Sensor
Capacitive Touch Sensor
Arduino Bluetooth Module HC-05 or HC-06
Arduino GPS Module (NEO-6M)
RFID
Turbidity Sensor
Load cell Module
PH Sensor Module
Pressure Sensor or Force Sensitive Resister (FSR)
Flex Sensor
CHAPTER 3
ARDUINO PROGRAMMING
Structure of an Arduino Code:
Bare minimum code
Arduino Data Types
Analog to Digital Conversion
ARDUINO PROGRAMMING BASICS
Structure
setup()
loop()
functions
{} Curly braces
; Semicolon
/*...*/ block comments
// line comments
Variables
Variable scope
byte
int
long
float
Arrays
Arithmetic
Compound Assignments
Comparison Operators
Logical operators
Constants
True/false
High/low
Input/output
if
if... else
for
while
do... while
pinMode(pin, mode)
digitalRead(pin)
digitalWrite(pin, value)
analogRead(pin)
analogWrite(pin, value)
delay(ms)
millis()
min(x, y)
max(x, y)
randomSeed(seed)
random(max)
random(min, max)
Serial.begin(rate)
Serial.printin(data)
Digital output
Digital input
High current output
PWM output
Variable resistor input
Servo output
Using Libraries
Summary
CHAPTER 4
ARDUINO PROJECTS LEARN BY DOING
Project 1: Blink an LED
Project 2: Interfacing with Keypad Module
Project 3: Multiple tones with one Piezo Buzzer
Project 4: Arduino Flame Sensor
Project 5: Interfacing with LCD 1602 Display
Project 6: HC-SR04 Ultrasonic Distance Sensor with Arduino
Project 7: Touch Sensor Arduino Interface
Project 8: Relay Module interface with an Arduino
Project 9: Control Servo Motor with Arduino
Project 10: Stepper Motor Control with Arduino
Project 11: Interfacing Soil Moisture Sensor with an Arduino
Project 12: Interfacing Sound Sensor Module with Arduino
Project 13: Analog Joystick Module with Arduino
Project 15: Interfacing DHT11 Sensor with Arduino
Project 15: One digit 7 Segment Displays with an Arduino
Project 16: Interfacing Bluetooth module HC-05 with Arduino
CHAPTER 5
ARDUINO PROJECTS IDEAS
1. Arduino Based Autonomous Fire Fighting Robot
2 Robot Snake based on Arduino controlled by Android
3. Smart Charger Monitoring System using Arduino
4. Automatic Sketching Machine Project
5.Arduino based Sun Tracking Solar Panel
6. Internet of Things based Irrigation Monitoring & Controller
System using Arduino
7. Internet of Things based Smart Agriculture Monitoring System
Project
8. Arduino Ultrasonic Sonar/Radar Monitor Project
9. Smart Dustbin with IOT Notifications
10. Open-Source COVID-19 Pulmonary Ventilator
11. Advanced Automatic Self-Car Parking using Arduino
12. Rotating Solar Panel Using Arduino
13. Touch Free Hand sanitizer dispenser using LDR
14. IoT Based Home Automation controlled by smartphone
15. Covid-19 Patient Monitoring Device based on LoRa using The
Things UNO
16. Open-Source Pulse Oximeter for COVID-19
17. Touch less doorbells can operate without touching the switch.
18. Social Distancing Device (Safety Card)
19. Automatic Faucet (Touchless) for COVID-19 Using Arduino
20. Obstacle Avoiding Robot using Arduino
21. Arduino Bluetooth with MATLAB for Wireless Communication
22. Coronavirus Sterilizer Box | Food Mask Sterilizer
23. Bluetooth Controlled Servo Motor using Arduino
24. Automatic Pet Feeder using Arduino
25. Arduino Based AC Home Appliances controlling with thermistor
and relay
26. IoT based Air Pollution Monitoring System using Arduino
27. IOT Based Dumpster Monitoring using Arduino & ESP8266
28. Weight measurement using Arduino, the HX711 Module, and a
load cell
29. Automated Plant Irrigation System Using Arduino with Message
Alerts
30. Arduino Motion Detector using PIR Sensor
31. Interfacing Hall Effect Sensor with Arduino
32. Smart Blind Stick using Arduino
33. Arduino Metal Detector
34. An introduction to Brushless DC Motors (BLDC) and how to
control them on an Arduino
35. Automatic Medicine Reminder Using Arduino
Summary

CHAPTER 6
How to Troubleshoot and Fix Arduino Issues
Can’t Load Programs on Arduino
Solution: Verify that the board model is compatible with the
configured model
Solution: Ensure a Functioning Arduino
Solution: Reset the Device
Solution: Diagnose USB Connection Problem
Arduino Software is Not Working
Arduino Software is Freezing and Crashing
Don’t Throw Damaged Arduino
Essential Resources
Bibliography
CHAPTER 1:
ARDUINO: EVERYONE NEED TO KNOW

Introduction
The first ever Arduino controller board was born in 2005, at the teaching
space of the Interactive Design Institute in Ivrea, Italy. An article about a
wiring design submitted by a Colombian scholar named Hernando Barragan
can be found in the Interactive Design Institute. The name of the proposal
thesis was “ Arduino - The Revolution of Open Hardware”. Of course, it
sounded a slightly different from the typical proposal but nobody would have
make-believe that it would be carve a niche in the domain of electronics.

The Arduino software IDE was developed by David Mellis and was based
on Wiring. Previously, Gianluca Martino and Tom Igoe joined the
development of Arduino mission, as well as the five are well-known as the
actual creators of Arduino board. They needed a controller should be
straightforward, easy to associate with different kind of module and
components (such as LED, motors, relays, and sensors), considerably
weightless, also easy to accessible in the open-source community, and simple
to program. It also wanted to be cost efficient, easy to available, because as
students and artists aren’t known for rich in cash. They choose the AVR type
of 8-bit microcontroller (MCU or µC) devices from Atmel and aimed a self-
sufficient circuit board with easy-to-use connections, put pen to paper
bootloader firmware for the microcontroller, and finished it all into a basic
integrated development environment (IDE) which used programs entitled as “
sketches.” The result was the Arduino Hardware.
Microcontroller
A minicomputer on a single chip, having a processor, input/output memory,
Analog to digital converter (ADC), and Digital to analog converter (DAC)
generally "embedded" inside some micro device which they control, a
microcontroller is often small and cost efficient.
Development Board

A printed circuit board contain a microprocessor and tiny or no hardware is


dedicated to a user interface, which designed to facilitate work with a
specific microcontroller is called development board.
In development board typical components include:
Power circuit
Simple input; usually buttons and LEDs
Programming interface
I/O pins
Here are some popular development boards listed:
Arduino
BeagleBone Black
Raspberry Pi
Intel Galileo
Goldilocks
pcDuino
Uruk
ExtraCore
What is the Arduino?

Why Was Arduino Developed?


Physical Computing - by means of components which able to interact
with people, besides by the world around us
The Arduino was initially developed for artists, inventors and
designers, to make prototype interactive displays
Intended for non-scientists, less knowledge required to learn.
Minimalist programming
“ Forgiving ” microcontroller board which able to handle a
widespread of wiring connection errors.
What can Arduino be used to Teach?
To understand preliminary electronics (voltage, current, resistance)
How electronic components, sensors and actuators works.
Elementary programming and troubleshooting
Design of simple scientific devices and equipment
Overcome the challenges of interactive with users via a DIY project
(e.g., messages, formatting numbers, ease of use, etc.)
Statistics and difference in data collecting and visualization
DIFFERENT TYPES OF ARDUINOS
The microcontrollers used in the various models of Arduino.

Arduino LilyPad

The LilyPad Arduino is a microcontroller board intended for wearables and


e-textiles. LilyPad is well known for its clothing-based projects. It can be
stitched to textile material, fabrics, cloth and likewise mounted power
source, sensors and actuators with conductive textile fiber.
Arduino BT

The Arduino BT is an Arduino board with built-in Bluetooth module, utilized


for various types of wireless communication, and remote-control application.
Arduino Esplora
Esplora is an Arduino board intended for gaming enthusiast fo r hassle-free
gaming experience and used as a Gaming Controller.

Esplora Arduino board consist of joystick, linear potentiometer (slider),


microphone, buttons control, temperature sensor, light sensor and three-axis
accelerometer, not the typical set of input/output pins.
Leonardo

Compared to the Arduino Uno, Leonardo is a minor upgrade.


It has built in Micro USB compatibility
Utilized to PC as a mouse or keyboard
Arduino Due

Arduino Due ha s much faster processor, and plethora of analog,


digital pins compared then Arduino Uno.
Due is similar to the Arduino Mega
Moreover, its works on 3.3 volts as well as 12v.
Arduino Nano
Arduino Nano is a superficial mount little microcontroller breadboard
embedded model with integrated Micro USB Port.

It is a tiny, full-fledged microcontroller, breadboard friendly, and cost-


effective device, it has everything like same as Die/Due/Uno board has
(electrically) with extra digital and analog I/O pins and onboard +5V AREF
jumper.
Arduino Micro
When size matters: Micro, Nano, and Mini, smallest board ever
made by Arduino developers.
Arduino Micro comprises all functionality of Uno and Leonardo
Arduino micro is simply working on a breadboard

Why use Arduino UNO?


Arduino is an open-source electronic prototyping boards based on
flexible easy to practice hardware and software.
Reasonably priced, we can buy Arduino less than $10.00, Provided
assemble your own Arduino board, or buying clone for more less
than in that.
Cross Platform IDE (Support in common Operating System such as
Windows, MAC, and Linux), Open-source IDE and extensions.

Fig. Overview of Arduino UNO


What Approach Have I Follow to Learn Arduino?
1. Start simple - build confidence learn by doing with small project before
going difficult one.
2. Practice components that will capture the thoughtfulness and imagination
of the students
3. Build a new project by modifying previous one.
4. Make a “problem” for pupils to resolve that THEY will understand
through practical however not too complicated
5. Find problem in your society, gather knowledge from it, make an idea,
then instantly do a development with it, and give a solution with your
project.
6. Teach pupils just how to find required info from datasheets (e.g.,
tolerances, current limits, etc.) and, likewise learn from the internet

Identification The first step to start a project is problem-solving process is


to identify, define, and articulate the problem. The use of brainstorming and
mind maps is valuable for some of the more difficult problems. Percolation
Data collection, research, and idea exploration are next steps. The main
reason that innovation is so difficult is because many ideas in a vacuum may
not seem realistic or appropriate.
GETTING STARTED WITH ARDUINO
Arduino IDE (Integrated Development Environment)
The Arduino Software (IDE) is easy to learn, and so far, flexible enough for
more creative people to take advantage of for educators, its user-friendly
platform related on the simple programming environment, therefore students
able to learn by doing Arduino codes in that environment will be related with
how the Arduino Microcontroller and its IDE workings.
A Computer for the Physical World:
The welcoming blue board in your hand (or on your workbench) is the
Arduino. In earlier you may think of Arduino as the child of a typical PC and
Computer system. By its origins, the Arduino is fundamentally a tiny portable
controller or a computer. It is responsible of gathering inputs (such as push
button or a sense from a LDR or light sensor) and understanding which data
to handling a number of outputs (Such as blinking an LED or an electronic
DC motor). Consequently, the term "physical computing" was born - an
Arduino is clever of interpretation the domain of electronics and linking it to
the physical world in a genuine and tangible approach. Trust me - this will
absolutely make more sense as early as possible you practice Arduino.
Installing Arduino IDE with Arduino Uno R3 board
STEP-1: Download the Arduino IDE (Integrated Development Environment)
from the official website link given below summary.
Access the Internet: with the purpose of get your Arduino controller
functioning, and before getting started, you have to download Arduino IDE
first from Official website www.arduino.cc (Arduino is Open Source, hence
need not to pay for it, it's free!). This Application, well-known as the
Arduino IDE, you can always ready to start write your own code for the
Arduino to do really what you want. Which is similar to a WordPad for
writing Arduino sketch.
With an internet accessible PC, open up your default browser and type in the
below URL into the web search bar: Download the newest version of Free
Arduino IDE from this page: http://arduino.cc/en/Main/Software
For dissimilar OS platforms, the method of using Arduino IDE is not the
same. Kindly ensuring to the following links:
Windows User: http://www.arduino.cc/en/Guide/Windows
Mac or Linux User:
http://www.arduino.cc/en/Guide/MacOSXLinuxUser
http://playground.arduino.cc/Learning/Linux
For learn more about Arduino IDE, Kindly checkout to the Link:
http://www.arduino.cc/en/Guide/HomePage
Arduino UNO SMD R3

Arduino Uno is one of the most widely used microcontroller boards,


powered by the ATmega328. Its wide range of support network and
versatility are the primary reasons for its popularity. In addition to the 14
digital I/O pins, the Arduino UNO board has 6 analog inputs, six of which
should be PWM (Pulse Width Modulation) outputs. An ICSP (In-circuit
serial programming) header, a 16 MHz crystal oscillator, a USB A/B port,
and a reset button. It's all right, you'll understand later.

STEP-2: Connect
your Arduino Uno to your PC or Laptop via Arduino cable, use the Type A/B
cable to connect to one of your Laptop’s USB inputs.

STEP-3: Installing Drivers


1. Depending on your laptop’s OS, you have to observe some
guidelines. Kindly checkout the official website URLs mentioned
below for particular guidelines on how to add or install the
drivers on your Arduino boards.
2. For Installing Arduino IDE for Windows Visit the official
website mentioned below to access the steps for Download
Software on a Windows Supported PC or personal laptop
http://arduino.cc/en/Guide/Windows
3. For Installing Arduino IDE for Mac OS X: Mac doesn't need to
install drivers. Visits the below web link if you have a query
http://arduino.cc/en/Guide/MacOSX
4. Installation Arduino IDE for Linux: Visit to the same web
address under the Linux categories mentioned below URL to
access the web pages to download Linux supported Arduino
IDE. https://www.arduino.cc/en/guide/linux

Afterward,
continue with the installation and please allow the driver installation step if
needed,

Select the tools or components to install and click “ next ” button to continue
Browse and Select
Destination folder or the installation directory
The procedure will extract and install all the necessary files to execute
accurately the Arduino Software (IDE) on system.
Step 4: How to open examples sketches or program on Arduino IDE.
Open Arduino IDE Software > File >Examples >Basics > Blink
Step 5: Choose your Controller board
For choosing board, you have to follow this entry in the Tools > Board list of
options which match up to your Arduino board.

Choosing an Arduino/Genuino Uno.


Step 6: Select your serial port
Choose the serial port of the board from the Tools > Port menu. This is
mostly to be COM3 or upper (COM1 and COM2 are commonly kept for
hardware serial ports). To discover, you be able to disconnect your board
and do the previous steps again, I mean re-open the menu; the entry which
disappears must be the Arduino board. Reconnect the board to the PC via
Arduino cable and choose that serial port.
TTL logic levels (5V or 3.3V depending on the board) are used for serial
communication on pins TX/RX. This pin should not be connected directly to
a serial port as it operates at +/- 12V and could result in damage to your
Arduino board.

Serial communication allows the Arduino board to communicate with a


computer or other devices. Serial is the name of one of the serial ports on all
Arduino boards (also called a UART or USART). In addition to USB
connections, digital pins 0 (RX) and 1 (TX) are used for communication.
Thus, digital input or output cannot be used on pins 0 or 1 if these functions
are used.
An Arduino board can be communicated with via a serial monitor that comes
with the Arduino environment. In the toolbar, click the serial monitor button
to select the same baud rate as calling begin ().
The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX)
and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), and Serial3 on pins 15
(RX) and 14 (TX). Because this board does not have a USB-to-serial
adapter, you will need a separate USB-to-serial adapter to communicate with
your PC. Connect the TX pin of your Mega to the RX pin of your external
device, the RX pin to the TX pin of your device, and the ground of your
Mega to the ground of your device to send and receive TTL serial data.
In addition to Serial1 and Serial2, it also has Serial3 on pins 15 and 14 (RX)
and on pins 17 and 16 (TX). Likewise, an ATmega16U2-TTL Serial chip is
connected to pins 0 and 1, which is connected to the USB debug port.
Furthermore, the SAM3X chip has a serial port that is compatible with USB,
SerialUSB. The Arduino Leonardo board interfaces with TTL (5V) serial
communications via pins 0 (TX) and 1 (RX) of Serial1. A serial connection
can only be used for USB CDC communications
Arduino IDE Interface
In the Arduino Integrated Development Environment - or Arduino Software
(IDE) - users can input code, view notifications, create text consoles, use a
toolbar with buttons for common functions and delve into menus. Connected
to the Arduino and Genuino hardware, it allows programs to be uploaded
and communicated with.

Step 7:
Upload the program
Here and now, just click the "Upload" button in the Header IDE Icons. Wait
just a second - you can see the RX and TX leds on the board flashing. Once
the upload is finished, you may see the message " Done uploading." will
seem in the status bar.
Step 8: Result
A couple of seconds later once the upload done, you could be able to see the
pin 13 (L) LED built-in on the Arduino board, it will ready to start blink (in
orange color), If it done… well done! You've understood basic Arduino
interface.
Arduino Libraries
The Arduino platform can be emerging into the next level through the
utilization of libraries, much like most programming environment.
Libraries offer an additional value meant for benefit in programming,
e.g., functioning with hardware or handling data. Large number of
Arduino libraries comes with built-in the software IDE, nevertheless
you can be able to download on websites or make your own.
You can express an Arduino Library is such a Class with
Methods/Functions. This is a great method to construct your sketches
There are three places where Arduino libraries are stored: inside the
IDE installation folder, inside the core folder, and inside your
sketchbook's libraries folder. Libraries selected during compilation
are designed to allow for updating of libraries present in the
distribution

For Instances:
Stepper Motor Library for an Arduino is written like
#include <Stepper.h> ‘.h’ is an extension for the library
header.
SD card library: Which means permits for reading from and
writing to the SD cards, for example on the Arduino shield for an
Ethernet and Wi-Fi modules
1. Ethernet Library for the Arduino is #include <Ethernet.h>
2. Wi-Fi library for the Arduino is #include <WiFi.h>
For writing your own libraries refer here:
Writing a good library is not an easy task. Developers have different
perceptions about what the appearance of a library like this should be. In my
opinion, developers should cover robust libraries with unit tests, as well as
provide detailed documentation. In addition, an intuitive and easy-to-use
interface is crucial for any decent library.
I have worked on several large software development projects most of my
career. The frameworks we used were robust, and we wrote proper unit tests
and integration tests for most of them. You'd probably spend more time
debugging if you didn't have well-written tests.
The Arduino kit I have been using for about a year and a half is very intuitive
to me. Aimed at hobbyists and self-taught programmers, Arduino was
developed by its creators. The community of people interested in electronics
is large; however, the quality of the published code is often very variable. I
often check the code on GitHub for Arduino libraries I need, but the code is
frequently unmaintained. Library materials were often not properly
documented, even when they were maintained. Unit tests weren't present in
most of them.
https://www.arduino.cc/en/Hacking/LibraryTutorial
https://www.arduino.cc/en/Reference/Libraries

How to add library files


Installing or adding Arduino libraries would be done by three different types
of steps:
1. Manually Adding the Library files,
2. Importing a ZIP compression file,
3. Adding Libraries with the library manager.
These Two approaches should be done with drop down menu options. On the
other hand, for the manual installation, we need to choose the libraries and
place that into the Arduino “ libraries ” folder.
Step 1: Add library file: Sketch>Include Library>Add.ZIP Library

Procedure for utilize an existing library in an IDE, just refer the Sketch
Menu, select "Include Library or Import Library", and choose required
libraries from drop down menu, Here #include is a supplement statement at
the first line of codes for both header (.h) file in the library space. As you
know these statements form the public functions and constants distinct by the
library existing to codes.
Step 2:
Choose your library file as zip format on the sample programming file, as
shown:
Step 3: Finish, Congratulation! You have learned how to install Arduino
libraries. For next session we will learn hello world of Arduino (Blink an
LED) program.

Hello World of Arduino (Blink an LED):


In this lesson, we will begin the journey of learn by doing with Arduino, let's
start your first Arduino Project, this is simple to get started, how to run blink
an LED.
Component Required:
1 x Arduino UNO
1 x LED
1 x USB Cable
1 x 220Ω Resistor
2 x Jumper Wires
1 x Breadboard

Principle:
In this project, we will program the Arduino's General-Purpose Input Output
(GPIO) HIGH level (+5V) and LOW level (0V), and before make sure the
LED that is linked to the Arduino’s GPIO, which is blink by a certain
frequency.
What is the LED?
The LED is stand for Light Emitting Diode. LED is generally made with
gallium arsenide, gallium phosphide both are semiconducting materials. The
LED consist of two electrodes: a positive and a negative electrode. This is
illuminating only after a forward current passes, then it will glow red, green,
blue, yellow, etc. The color of the LED is depending on the material that is
used.
Generally, 5-20mA is drive current of the LED. So, in actuality, it generally
requires more resistor for limiting current, because of protect the LED from
the high current.

What is resistor?
The important role of the resistor is used to limit currents. In general,
electronic circuit, the letter ‘R’ denotes resistor, moreover the unit of resistor
is ohm (Ω).
Writing an Arduino sketch
Before developing an Arduino code, we have understood some basic
Arduino C functions, we may learn in upcoming lesions…
Basic Arduino C functions:
Here is some essential Arduino functions, and commands everyone need to
know before write a code.
setup()
The setup() function is known for what time a code starts. Useful to initialize
variables, start utilizing libraries, pin modes, and more… The setup function
may simply run once at a time, afterward to each activate or reset of the
Arduino microcontroller.
loop()
When making a setup() function, that initializes and use the initial values, the
loop() function do from exactly what its label recommends, in addition,
loops repeatedly, letting your sketch to change and respond. Utilize it to
dynamically regulate the Arduino board.
pinMode() / pinMode(var1, var2)
Arranges the definite pin to work each as an input or an output. Set the mode
of assumed pin is pinMode functions. Var1 is known as the number of the pin
and var2 is known as mode (I/O).
digitalWrite() / digitalWrite(var1, var2)
digitalWrite alters the status of the pin. Var1 is known as the number of the
pin and var2 is the status (HIGH, LOW).
delay()
delay() Function can be used for pauses the codes for the certain amount of
duration (in milliseconds) stated as parameter. (1 seconds is equal to 1000
milliseconds.)

Procedure of Blink an LED Projects:


Step 1: Build the
circuit for blink an LED as shown below:

Pin definition
LED UNO R3
Long pin -> +5V (D13)
Short pin -> GND

Note: The lengthy LED pin is linked to the digital signal port 13(D13).
Step 2: LED Blink: Write your first code on Arduino IDE.

Uploading the Sketches


Before Uploading sketches make sure you are connected your
Arduino board to the USB cable (Types A/B).
Make sure if you choose right Arduino Board on tools menu follow
these steps to choose desired controller board Select
Tools→Board→Arduino Uno to find your board in the drop-down
menu. You be able to choose various types of microcontroller boards
from this list, such as the Arduino Nano, Arduino Uno and Arduino
Mega.
Also, the essential stages are select the right serial port for your
Arduino board. You can see all the existing COM serial ports by
selecting Tools→Serial Port→ comX, In IDE, once you have
recently connected your Board to Computer, the COM port may
typically be the bigger number, for e.g. COM 3 or COM 15.

Click Verify Button for the code is checked once before uploading
Click Upload Once Click the upload button, then the code is dump to
the Arduino Microcontroller board.
Step 3: Compile the sketch and upload to Arduino
board. Congrats! Finally, you finished your
Arduino Project Blink an LED. Let’s see the Question-and-Answer Session
about Arduino Platform.
Arduino Q & A Section
1) What is the Arduino used for?
Arduino is an open-source electronic prototyping boards utilized for flexible
easy to practice hardware and software. An Arduino microcontroller board
can read inputs (a light on a sensor module, a tweet on Twitter, a finger
touched a switch), and use that data to trigger a motor, blink an LED, and
broadcast data to the internet.
2) Who invented Arduino?
Massimo Banzi
In 2005, Hernando Barragán (maker of wiring), Massimo Banzi and David
Cuartielles are building upon the work on developing open-source
microcontroller, finally Arduino born. Their goal was to develop a
collaborating art design module that could be easily accessed via a
programmable interface at the Interaction Design Institute Ivrea in Ivrea,
Italy.
3) Who uses Arduino?
Arduino developed for student, hobbyists, artists, designers and any person
fascinated in building interactive project or environments.
4) Is Arduino based on C or C++?
Primarily, the Arduino IDE or compiler support C and C++. Actually, most
of the Arduino libraries are written by C++ Programming. Most of the
fundamental structure is not object oriented, however it could be. Therefore,
"The Arduino IDE language" is C++ or C.
5) Is Arduino good for beginners?
Yes, Arduino is good for beginners, which they able to buy on a budget, an
Arduino Uno is a worthy choice. There are several basic programming/
sketches that will support on the Uno, Novice learner also allowing to
evaluate Arduino and practice as a wonderful knowledge gaining platform,
and most of the mini projects can be designed with an Arduino Uno.
6) How does the Arduino work?
An Arduino board is connected to your laptop by a USB type A/B cable, in
order to connect with the Arduino software since it's nothing but the Arduino
IDE (Integrated Development Environment). This is done using an IDE that
creates sketches and code, which is then sent to the Arduino microcontroller
for execution. Afterwards, the application interacts with sensors, electronic
components, motors, and lights.
7) What is the difference between Arduino and microcontroller?
Many of the board often use Atmel types of AVR microcontrollers. Arduino
UNO is an ATMEGA 328 based microcontroller series. Most commonly
Microcontroller is a well suited than a microprocessor to whatever needs the
recognizing of inputs.
8) How do I start Arduino?

Getting Started with Arduino UNO, Nano and Mega.

Practice your Arduino Uno on the Arduino web/online IDE.

Use your Arduino on the Desktop software IDE. Install or choose the
board drivers. Start your initial sketch. Choose your controller board
type and port. Upload the Sketch/program, furthermore study on the
Software IDE Tutorials.
9) Is Arduino software free?
Yes, Arduino is an open-source hardware and software , almost all the
open-source product is free, and Therefore Arduino is a free platform, we
can able to modifying Arduino module without getting any license from
Arduino developers.
10) How do I power an Arduino?
We able to power-up the Arduino with power supplied from the
laptop through a USB type A/B cable or by utilizing external power
sources, such as power bank, li-ion batteries up to the 12V.
Plugged into the barrel connector with Arduino by using an AC to DC
adapter.
Powering up Arduino by using all types of 5V DC input. ...
Moreover, we can use batteries higher than 5V.
11) What is the programming language of Arduino?
The Arduino language is just a set of C/C++ functions which can be so-
called from your sketch. Your code feels minor modifications (e.g., automatic
creations of function prototypes) as well as then is accept straightly to a
C/C++ compiler (avr-g++).
12) What chip does Arduino use?
Arduino uses ATMEGA328 Microchip, which contain 14 digital
input/output pins, 6 analog inputs, 6 pins can be utilized for Pulse-width
Modulation (PWM) outputs, also includes a 16 MHz quartz crystal, a power
jack, a USB connection support, an ICSP (In-Circuit Serial Programming)
header, and a reset push button.
13) Does Arduino have a CPU?
The Arduino Uno doesn’t have a CPU, but it uses a microcontroller named
ATMEGA328. In an Atmega328 microcontroller include the processor core,
programmable I/O and memory, peripherals are incorporated into a single
System on Chip (SoC). However, the microprocessors possibly will have
integrated registers, nevertheless it will depend on outward RAMs and
peripherals.
14) Which is better Arduino or Raspberry Pi?
A microcontroller is a portable easy-to-use computer which be able to run
one sketch/program at that moment, over and over again. Microcontroller is
extremely straightforward to use. A Raspberry Pi is a general-purpose credit
card sized motherboard, also utilized as a portable computer, generally
Raspberry Pi is support by Linux OS, and it have the capability to run
various programs. It is further more complicated to learn than an Arduino.
15) How is Arduino different from C?
The primary dissimilarity of Arduino vs Traditional C would be the file
associations . An Arduino software development is associated to the IDE
(Integrated Development Environment) of Arduino, which is ultimately a
C/C++ compiler that creates machine sketch for the Arduino boards.
16) Can an Arduino run 12v?
Arduino Power pin labeled as Vin, it is a input voltage in Arduino board (As
an alternative of utilizing the barrel adaptor or USB cable). The Arduino
voltage should be 9V to 12V, and which is regulated inside by the board to
5V.
17) What is the best Arduino?
Arduino Uno: Provided you are a novice learner, entering into the field of
Arduino, the great choice for you would be the Arduino Uno R3, which costs
around $20. Moreover, you can also buy clone boards such as Freeduino
which cost around $5, you may also get started from this too.
18) Why Arduino Uno is best for beginners?
Arduino Uno is the most popular and standard board available in the market
and most likely the primary option for the student. For the reason that, it has a
major benefit is, that we able to use the board to the computer through a USB
cable which does a dual purpose of delivering power to the board and
performing as a Serial port to interface the Arduino microcontroller and the
laptop.
19) Is Arduino difficult to learn?
The worthy information is that Arduino programming is merciful. It still has a
learning curve, and writing an Arduino code it's not just simple, however it
will be much simple than write sketches for your initial projects, to be sure,
Arduino should be a stress-free technique to wet your feet in coding.
20) Is Arduino a PCB?
For dumping code to microcontrollers, for simple user interface the Arduino
Environment provides an IDE, which is created for making right code for
project, Arduino IDE integrated with C and C++, that’s to say, a PCB is not
the similar as an Arduino, but a PCB is portion of Arduino.
21) Can Arduino run without computer?
So, we have a query… Can we run Arduino as a portable device and no
computer needed? Yes, Laptop only sufficient to program it, after dumbing
the code, Arduino can work as portable device with power source. Yes,
Here Wi-Fi module and Ethernet also existing for connecting it to a network.
... But the Arduino is not effective to run software for that.
22) Can we use Java for Arduino?
We able to use Java SE Embedded or Java ME on a Raspberry Pi, on the
other hand, the Arduino is a slightly too forced to execute Java directly.
Though, with the support of serial port communication IDE, we able to
communicate with java also control an Arduino from Java running on a
different PC.
23) What is Arduino in IOT?
At the present time a buzzword field and fastest growing area is Internet of
Things (IoT), IoT project is nothing but, all the physical things such as home
appliance, sensors, and gadgets are linked together with an internet structure.
IoT utilized in Plethora of Application such as Home Automation, Smart
Agriculture system, and Smart-Health monitoring system.
24) What is the smallest Arduino?
Arduino Beetle is the smallest Arduino microcontroller available in the
market. It has AtMega32u4 8bit AVR Microchip, It has 10 digital pins, 5
analog pins and 4 Pulse with Modulation pins, Beetle board functioning with
16MHz clock time.
25) What can the Arduino beetle do?
Beetle intended to make a Cost-efficient microcontroller, it should be simple
and straightforward to use, and to afford a cost-efficient solution for reusable
projects, Like DIY STEAM projects, electronic workspaces, E-Textiles, gift
projects, and Practical Education. Aimed for students, research scholar and
creators those who can’t afford too much on controller module purchasing,
Beetle should be a wonderful solution for them.
26) What is the difference between Arduino Uno and Leonardo?
The Primary modification between Uno and Leonardo is which Leonardo has
an ATmega32u4 Microchip that contain inbuilt micro-USB port, but the
Arduino UNO has ATmega328 Microchip which doesn't have the inbuilt
micro-USB onboard. However, the UNO needs an added microcontroller to
provide the USB capability. Cost wise Leonardo is 20%. Cheaper than UNO.
27) Which is better Arduino Uno or Nano?
As its name, Arduino Nano is a small in size and breadboard-friendly
microcontroller board based on ATmega328 processor, as a replacement for
the standard USB to connect to the PC, Instead Arduino Nano utilized the
Micro USB but without the power cable for external power source which
built on Arduino UNO.
28) What can the Arduino Nano do?
Arduino Nano is a more or less similar board to Arduino UNO in terms of
functionality, but its small size makes it stand out from other boards. A
breadboard-friendly, smaller-sized ATmega328 module built on the
ATmega328, the Arduino Nano is small in size, wide-ranging, and
breadboard-friendly.
29) Does Arduino have EEPROM?
In the Arduino Microcontroller boards, the EEPROM area is emulated and is
1024 bytes in size. Microcontrollers on Arduino boards are AVR-based and
include EEPROM memory, allowing them to retain their values after being
turned off (such a small hard drive). These EEPROM bytes can be read and
written with this Arduino library.
30) What is the use of EEPROM in Arduino?
This memory type is referred to as electrically erasable programmable read-
only memory. On the majority of Arduino boards, the microcontroller is built
with EEPROM capacity of each 512 bytes, 1024 bytes, or 4096 bytes.
Memory storage on this board is non-volatile, which means once the board
goes down or loses power, the information does not disappear.
31) Can Arduino save data?
Provided Arduino is interfacing to the PC, the information can be stored by
reading the serial output and saving that in a file. Provided a Micro SD card
insert to the Arduino, the files or information can be stored straightly to the
SD card.
32) What are the Different Types of Arduino Boards?
Arduino Uno (R3)
Arduino Mega (R3), Arduino Beetle
Arduino Nano, Mini
LilyPad Arduino, RedBoard Arduino
Arduino Leonardo
Arduino Shields and more...

Summary
This chapter introduces Arduino and shows you how you can get started with
the microcontroller and addresses frequently asked questions. In the next
chapter we will explore the basic components of electronics and different
types of Arduino-compatible sensors and their functions.
CHAPTER 2:
BASIC ELECTRONIC COMPONENTS
In Arduino projects, major components typically included resistors,
capacitors, transistors, integrated circuits (ICs), switches, relays, motors,
etc. Usually, these components are used to build Arduino projects, so before
we dive into Arduino sensors and projects, we need to learn about basic
electronic components.
Resistors
A resistor impedes the movement of electricity over a circuit, resistors have
a conventional value.

Since voltage, current and resistance are associated over Ohm’s law,
resistors are a simple technique to control voltage and current in your circuit.
Resistor color codes
Color Code Number: (BBROYGBVGW)

Unit
To Identifying your units is significant
Kilo & Mega are basic in resistors
Milli, micro, nano & Pico can be utilized in additional components

Capacitors
A capacitor is used to stores electrical energy. Here pool of electrons is
obtainable for electronic components to usage.
Capacitance is measured in the unit of Farads. The mini capacitors typically
used in electronics are often determined in micro-farads and Nano-farads.
Some capacitors are polarized. Have to know the different length of
terminals on one of the capacitors.
Polarity of capacitors
The smaller terminal goes on the -ive side.

The strip is on the -ive terminal


sideways of the capacitor.

The panel is noted for +ive or -ive.

Applications of capacitors
Capacitors can pass a pool of electrons for instant use.
If a component wants an instantaneous supply of electrons, the
capacitor can pass those electrons.
Capacitors can smooth out a
signal - remove the waves or spikes in DC voltage. The capacitor can attract
the peaks and fill in the vales of a waved signal.
Inductors
An inductor is a passive electronic component which is stores energy as a
magnetic field. In its minimum tough form, an inductor includes of a wire
loop or coil. The inductance is straight proportional to the amount of turns in
the coil. Inductance similarly relies upon the distance of the coil and on the
kind of material about which the coil is wound.

An inductor, similarly called a coil, choke or reactor, is a passive two-


terminal electrical component which stores the current in a magnetic-field
once electric current pass through it. An inductor usually includes of an
insulated wire twisted into a coil about a center.
Transformer
A transformer is a static-electrical device which exchanges electrical current
among at minimum two circuits over electromagnetic acceptance. A changing
current in one coil of the transformer makes an opposing magnetic field, that
thusly prompts a shifting electromotive force (emf) or "voltage" in an instant
coil. Energy can be exchanged among the two coils, without a metallic
suggestion between the two circuits.

Faraday's law of inductance found in 1831 portrayed this influence.


Transformers are utilized to increment or lessening the rotating voltages in
electric energy applications.
Diode
A diode is a one-way controller (or gate) for electricity. Diode is a
component by an irregular transfer characteristic.
A diode has little (preferably zero) resistance in one way, and high
(preferably infinite) resistance in the other way.

Diodes will protect your electronics


Diode circuit protection
In a DPDT switch, if polarization is incorrect, the motor will run
backwards. In an electronic circuit, if the polarization is incorrect,
you can fry your components.
A diode in your scheme will assistance to avoid problems.

Light emitting diode (LED)

A light emitting diode (LED) is


a semiconductor light source. Once electricity is flow through the diode, it
produces light.
Variable resistor (Potentiometer)
A potentiometer is a variable resistor. As you physically turn a dial, the
resistance variations.

How a variable resistor works


As the dial or wiper turns, electricity essential go through more or less of the
resistive strip.
In sequence, the variation in resistance means a variation in voltage, so as
you turn the dial or wiper, you become a variation in voltage
Transistors
A transistor is a semiconductor device applicable to switch and amplify
electrical power and electronic signals.

How a transistor works


The passage of voltage or current between the terminals of a transistor
varies the current over different pairs.
Transistors are semiconductor elements arranged in a package with at
least three terminals for the purposes of connecting to external circuits.
Transistors have 3 pins, there are five different types of transistors
1. Collector
2. Emitter

3. Base
Bipolar Junction Transistor (BJT): There are two different types of
transistors available in the market: NPN and PNP, presented in plastic cases
or metal cans. Plastic casings have a flat front side and pins arranged in a
serial manner on one side of the transistor. You can identify the pins by
counting them as one, two, etc. by keeping the front flat side facing you.
There will typically be three transistors in an NPN transistor: 1 (Collector),
2 (Base), and 3 (Emitter). Thus, the CBE. But in the case of PNP transistors,
the condition is reversed. In other words, that's EBC.
Field Effect Transistor (FET): A Field Effect Transistor can be identified
by starting counter-clockwise, keeping the curved portion facing you. The
first one is the source, the next the gate, and the last is the drain.
MOSFET: Metal Oxide Semiconductor Field Effect Transistor: It is not
uncommon for the pins of a MOSFET to be labeled as G, S, and D, which
indicate the gate, source, and drain, respectively. The datasheet for the
MOSFET may need to be consulted in some cases. As you make your way
from left to right, normally you want to make sure the flat side of the pin is
facing you.
IGBT- Insulated Gate Bipolar Transistor: With some practical IGBTs,
like the GN2470, the raised surface faces the person holding it so that the
short surface in the center acts as the cathode. Those on the left are Gates,
and those on the right are Emitters.
Phototransistor: In a practical phototransistor like the L14G2, the collector
is on the curved surface facing the person and the emitter is on the other side.
The base is on the side opposite the emitter.

Schematic symbols

Integrated circuit (IC)


An integrated circuit (IC) is a group of transistors which is the controller or
‘brain’ of an electronic circuit. An input is received, an output is sent out.

Current microprocessor ICs can have billions of transistors each square inch,
The majority of electronic devices contain some form of integrated circuit. A
timer is an electronic device that functions as an amplifier, a logic unit, a
counter, a calculator, a temperature sensor, and a radio receiver. Electronics
have been revolutionized since integrated circuits are present in almost all
modern equipment.
ICs are physically much smaller than discrete circuits. Contrary to discrete
circuits, an integrated circuit is very light in weight. Compared to other
systems, it's more reliable. It has a lower power consumption due to its
smaller size. Failures can easily be replaced, but the failure can almost never
be repaired
What an IC can do for us?
Billions of electronically measured on/off switches (transistors) is
how the microprocessor in a digital computer ‘thinks’ and purposes.
A computer has a wide variety of tasks to perform.

But
other ICs can fully simpler, separate jobs. For i.e., an IC can take a
voltage input and output instructions to a motor.

IC Terminology: Op-amp

An
operational amplifier (op-amp) is a group of transistors inside the IC
(Integrated Circuit). They frequently are the components doing the
mathematical procedures.
An operational amplifier amplifies weak electric signals by using an
integrated circuit. Two inputs and one output are present in an operational
amplifier. The input voltage difference between the two input pins is
amplified and output by this driver.
The most common type of voltage amplifier is the Op-amp, which can be
broadly categorized into non-inverting and inverting amplifiers.

H-bridge
An electronic circuit which allows voltage to be applied across a load in any
direction.

A DPDT switch also does this, but not electronically


Varying voltage
A potentiometer or variable resistor permits you to variation the
voltage input which goes into the integrated circuit (IC).

Integrated circuit can now output change of pulse widths to the


transistors on the H-bridge.
This grouping of potentiometer, integrated circuit and PWM to the H-
bridge is the key to speed controller.

Printed Circuit Board (PCB)


The ‘front’ side of the board will have printed component information, such
as resistor and resistance, diode type and polarity, Components are attached
to a printed circuit board.
Holes go all the method over the board since one side to the other. Over hole
soldering is needed to join components to the board.

Backside of Circuit Board


The ‘back’ side of the board will have lines indicating contacts between
components. The lines on the back are alike to wires, Denser lines denote
extra current (electrons) moving through, Components connect the lines.
Merits and its Application
Smaller size and less wire are required. PCBs with several electronic
components are called characteristic PCBs. Copper tracks are used to
connect components on a printed circuit board instead of a number of wires
carrying current. This reduces the size of the interconnections.
Various electronic devices including calculators , mobile phones, printers,
and LCD televisions utilize flexible circuits, Cameras, a heart monitor, a
pace-maker, and hearing aids are made using these materials. Robotic arms,
processing equipment, bar code equipment, etc., are among the products they
manufacture.
WHAT ARE SOME GOOD COMPONENTS TO START WITH?
LED (Light Emitting Diode)

Many of Light Emitting Diodes with range of colors (Make sure to


similarly get two or more resistors for limiting current)
LED has an illuminating feature which can be utilized for space as an
actuator.
Used for Flickering, blinking, dimming with PWM, “Adventurer Rider”
result by 7 or more LEDs, strobe special effects, etc.
Due to the fact, a Light emitting diode is a directional part, means that,
which is stimulated simply if it is located in right direction with the
circuit.
LCD (Liquid Crystal Display)
A LCD is a types of optical display most commonly utilized in electronic
modules, in that a group of a liquid crystal is sandwiched among two
transparent electrodes, this process play a vital role by making an LCD.

The LCD contains of 16 pins which are utilized for power, control, in
addition data. It should follow a manufacturing standard Hitachi regulator
therefore the basic functions of LCD are almost similar across the various
kind of traders that sell them. They both have a 4-bit and an 8-bit parallel
interface. We have been utilizing 4-bit parallel interface instead of 8-bit.
Which means we will be transmit the upper nibble (1 nibble is equal to 4
bits) first, next to the lower nibble to transmit the byte of information
essential for each command or character. LCD 16×2 or a 20×4 is most
generally used in many projects that means which it can be show 16
characters on both 2 lines and 20 characters on both 4 lines, correspondingly.
LCD Pinout with an Arduino interface circuit shown below.
Why start with LCD?

The LCDs support a parallel interface, significance which the Arduino has to
handle numerous interface pins simultaneously to control the display. The
parallel edition capable 4 digital pins for display, Learners definitely
express vast degree of happiness from sending word to the LCD screen
DC Motor

A DC (Direct Current) motor is one of the popular varieties of electronic


motor. It generally consists of two terminals, which is positive and negative
terminals. Once you connect these two terminals straightly to a power source,
the DC motor will rotate. If you change the terminals, the motor will rotate in
the reverse side.
Threat - Do not operate the DC motor directly from the Arduino board pins.
This can be causes of Arduino circuit failure. Therefore, we should have
used a driver circuit or a motor driver IC for before controlling all variety of
motors.
Servo Motor
There are huge variety of servo motors existing in the marketplace and to
each one has its unique characteristic, futures and usages. The upcoming
lesson will assist you recognize the right type of servo motor for your mini
project/invention.

Many of the electronic servo motors operates from 4.8V to 6.5V, if we give
high voltage, simultaneously we able to get high torque, However, usually an
electronics Servo motors are functioned at +5V. More or less all hobby
servo motors must be rotate just from 0° to 180° because of its gear
placements therefore validate your mini project be able to work with help of
the half circle if no, you be able to choose for a 0° to 360° motor or
adjustment the motor to modify a full circle . In motors the gears are simply
subjected to wear with tear, therefore if your project needs robust and long
durable running motors, you can choose metal gears or else just go with
typical plastic gear.
After picking the desired Servo motor for our project, the queries will come,
how to use it. As we know already servo motor having three wires, there is
power, ground, and a third wire to bring the signal. For rotating the servo
motor, we want to connect the battery to at +5V with the Red and Brown
wire as well as Transmit Pulse Width Modulation (PWM) signals to the
orange wire. Therefore, we must rather that may produce Pulse Width
Modulation signals to make the servo motor rotate well. We can able to
utilize this hobby servo motor with any electronic development board such as
555 Timer or further more microcontroller environments such as Arduino,
ARM, PIC, or even though a credit card sized computer or microprocessor
such as Raspberry Pie.
Applications
Hobby Servo motor utilized as actuators in various kind of robotic
projects such as Robotic arm, Biped Robot, and Hexapod, and
more….
Frequently using in RC toys as steering control system,
In Robots, doesn’t required feedback for position control,
Because of weightless, and little in size, as a result the servo motors
utilized in multi-purposes DOF (Degree of Freedom) robotic
application such as human-like robots.
Stepper Motor

A Stepper Motor or a step motor is a brushless synchronous Motor that splits


a complete rotation into a small number of steps. Not like a brushless DC
motor, that rotates constantly once a stable DC voltage is passing to it,
subsequently a step motor will rotate in discrete step angles.
Stepper motors, because of its extraordinary design, which be able to control
to a large degree of precision with no feedback system. The shaft in the
stepper motor, attached by a sequence of magnets, which is managed by a
group of electromagnetic coils which are electrified positive and negatively
in a particular order, Accordingly, it exactly rotating it clockwise or
anticlockwise in a little “step”.
Here we can see two kind of stepper motor, Unipolar and Bipolar, and this is
most essential to know which variety you are dealing with. For each of the
stepper motor has unique design in structure. Many of the stepper motors are
constructed or designed by steps per revolution of 12, 24, 72, 144, 180, and
200, subsequently steps moving angles is 30, 15, 5, 2.5, 2, and 1.8 degrees
per step. We able to operate with or without feedback to the stepper motor.
Visualize a motor on a RC (Radio-controlled) aircraft. The motor rotations
are extremely high in one direction or another. We be able to change the
ROTATION of motor by change the level of voltage given, but we cannot
convey to the propeller to END at a particular position. Now visualize a
printer. Here is plenty of movable parts inside a printer, also consist of
motors. Imagine those motor acts as the rotating rollers, paper-sheet feed
which travel the slice of paper as ink is being printed on it. This motor
should be able to run the paper-sheet an accurate distance it can be print the
following line of word or the next line of a picture.
Stepper Motor Control
We discussed previously how to generate the magnetic field with which the
rotor is going to align by energizing the motor coils in a specific sequence. It
takes multiple devices to supply the coils with the necessary voltage,
allowing the motor to run properly. Taking a look at the closest devices to the
motor, we have:
An electrical connection between the motor coils is physically
controlled by a transistor bridge. The transistors can be viewed as
electrically controlled interrupters, which allow an electrical current
to pass through a coil when they are closed. For every motor phase,
one transistor bridge is required.
It is controlled by an MCU, with which it provides the voltage and
current needed to trigger the transistors.
The MCU is a microcontroller unit, which is typically programmed
by a motor user, that generates specific signals to the pre-driver,
allowing the motor to perform as desired.
How a Stepper Motor Works?
A typical DC motor can rotate simply in specific position; however, a
Stepper motor be able to spin in exact steps.

Stepper motors be able to rotate a precise number of degrees (or steps) as


required. Which delivers total control to the motor, that permitting you to
change it to a particular position, and grip that spot. Indeed, hence with
electrifying the coils on inner part of motor aimed at precisely small time
period.
Everyone have to know for nowadays is that, to spin a stepper motor, we
have to give command it to spin a specific number of steps in one position
or the another, and also convey it to the speed at which steps in that position.
The drawback is which you have to always give the power supply to motor
to retain it in the spot which you want.
There are many advantages to stepper motors
In the right environment, stepper motors can be ideal, although not all
applications will benefit from them.
The first thing to note about stepper motors is that the torque they
produce is full at standstill, and the direction of rotation is
proportional to the input pulse.
With stepper motors, you can control the speed, position, and
repeatability of movement in excellent ways.
Additionally, since stepper motors are not fitted with contact brushes,
they are very reliable. Maximizing the motor's operational lifespan
by minimizing mechanical failure is made possible by this technique.
These motors are suitable for a wide variety of applications, as
various rotational speeds can be achieved due to their inverse
relationship with pulse frequency.
There are many uses for stepper motors, but here are some of the most
common:
Machines that print 3D objects
Machines that produce textiles
There are several types of printing presses
A machine for playing games
Imaging equipment for medical use
Robotics for small spaces
Milling machines that use CNC technology
Stainless steel welding equipment
Despite the fact that stepper motors are most commonly used for these
applications, they represent only a fraction of what they're capable of. In
general, stepper motors can be used for any application that requires highly
accurate positioning, speed control, and low speed torque.
LIST OF ARDUINO SENSORS AND MODULES
Sensors Input/Output

Fig. Theory and Practice of Physical User Interfaces


Ultrasonic Sensor Module

Ultrasonic Sensor - Utilize the ultrasonic waves to measure the distance


between sensor and obstacle or any object, depending on time duration
among transmission of ultrasonic wave and Receiving echo of it. HC-SR04
Ultrasonic module has four pins: there is Trigger, Echo, Vcc+, and Ground
The ultrasonic module has built-in transmitter and a receiver which
functioning at standard 40 kHz operating frequency. This frequency is not
including the hearing range of human and animals, Accordingly Humans be
able to hear the sounds in a frequency range only from around 20 Hz to
20 kHz.
IR Infrared Obstacle Avoidance Sensor Module

IR Infrared sensor that will emits infrared radiation which bounced back by
the obstacle or objects in proximity sensor. After sensed by a digital output is
shown. Level of Sensitivity is might be adjusted by on-board variable
resister or potentiometers. It will very effective for sensing a robot is around
to interface with walls or other obstacles.

IR Sensor Module Features


It will be operating at 5V DC.
Input/Output pins are flexible at 5V and 3.3V.
IR Sensor Module Range is up to 20cm
Sensing range of IR Sensor can be Adjustable
Module include Built-in Ambient Bright Sensor
Support a Mounting hole
Supply current is approximately at 20mA.
The IR LED or transmitter will be emitting an infrared waves or signals
which, just in case of a reflecting surface such as white color walls, it
should be spring back in opposite directions within that of the photodiode
nothing but IR receiver that acquired the waves by sensing the obstacles or
an object.
In case of an absorbent surface such as Black color walls, it can’t be
reflected and the object cannot be detected by the sensor. This result may
come even if the object is absent.
IR Infrared Fire/Flame Detection sensor

Fire Detection Sensor Module is much sensitive to the Smoke, flame


nevertheless correspondingly can be sensing traditional light, and generally
this is utilized as a fire alarm, Senses a smoke or else a luminance source of
a wavelength in the range between 760nm-1100 nm.
IR Infrared Flame Sensor has difference characteristics such as Sensing point
is nearly 60 degrees, mostly sensitive to the flame spectrum, steady
performance, sensitivity is flexible.
Applications of IR Sensor
IR Infrared Fire Detection Sensors are applicable in various types of
Emergency conditions which include the following.
1. Applicable in Hydrogen stations and identification for an Industrial
heating
2. In the majority of fire detection projects, an IR sensor is used
3. Many industries use fire alarms as a fire emergency device
4. On firefighting robots, the flame detector module is used.
5. Detecting the presence of gas in kitchen devices powered by gas
6. Additionally, it is used in gas turbines, drying systems, and domestic
heating systems

Soil Hygrometer Detection or Soil Moisture Sensor

Soil Moisture Sensors can be precisely sensing the amount of moisture or


volumetric content available from the water in soils (such as from flower
pots). These are much beneficial for Arduino agricultural projects.
The Soil Hygrometer is used capacitance to senses dielectric permittivity of
the nearby range, at the soil dielectric permittivity is a role of the moisture
level. Which a sensor makes a voltage relational to the dielectric
permittivity, in addition as a result the moisture level of the soil.
Soil-Moisture Humidity Sensing Module is utilized to identify the moisture
content of the water. This module is extreme sensitive to the environment
moisture. Once the soil is going to dry the sensor outputs will be in high
level, or else outputs low. Soil moisture sensor is utilized in variety of an
autonomous application such as automatic irrigation system, accordingly the
plants in the farm can be automated without human assistance.
Humidity and Rain Detection Sensor

Humidity Detection Module also known as Rain Sensor that is engaged to


sense the rain water and then trigger an alarm. Accordingly, we will preserve
rain water to utilize it for future application. Here is plethora of techniques
exist for save water such as Rain water harvesting. By using this way we be
able to raise the level of ground water and utilize it’s for crisis situation.
Therefore, we can use Humidity and Rain water sensors for various kind of
application such as Agriculture Irrigation, communication, automation,
automobiles, etc.
What is a Rain Sensor?
A rain sensor is unique types of switching module which utilize to sense the
rainfall. This sensor mechanism similar to the switch, as well as the
operational functions of Rain water sensors, at whatever time there is rain,
the switch can be normally closed.
Rain Sensor Module
The rain sensor module be made of nickel coated lines and that is based on
the resistance principle. This module can be estimate humidity via analog
output pins and that provides digital output whereas water level threshold
surpasses. This sensor is analogical to the LM393 IC since which consist of
electronic module and PCB board.
How does it Work?
In straightforward terms, the resistance of the collector board fluctuates
according to the level of moisture taking place its surface.

While the Sensor is in Wet: the resistance will Surges, and the output
voltage will decline.
While the Sensor is in Dry: the resistance is declines, and the output
voltage is Surges.
Microphone Sensor or Sound Sensor

Arduino Sound Sensor contains a sensitive capacitance mic for sensing


sound and comes with built-in amplifier circuit, the digital output reacts as a
key, and it will trigger, once the audio intensity has achieved a specific
threshold level. The sensitivity threshold can be increase or decrease through
variable resister on the module.
The analog output voltage is fluctuating by the intensity of sound acquired by
the microphone module, we may connect this sensor output to Arduino analog
pins and then we can able to process the output voltage, each microphone has
digital and analog outputs.
AO: Analog Output, to output voltage signals from microphone in a real-
time manner
DO: Once the audio intensity archives a specific threshold level, the
microphone outputs will be high or low level.
There are two types of microphone sensor available in the market:

1. Standard Microphone Module and


2. High-Sensitive Voice Sensor.

‘ Sensitivity Level’ is the one and only dissimilarity for both microphones
Digital Barometric Pressure Sensor
The Barometric Pressure Sensor (BMP180) is one of the fascinating sensor
modules available in the market, important role of this module is measuring
the pressure and altitude, which can be used to forecast the climate
conditions, sense altitude, and estimate perpendicular velocity, it’s a
tremendously sensitive sensor on top. By means of you can realize in a
second, it can be sensing the fluctuation in altitude of just a few inches.

This Barometric Pressure Sensor can be used in various kind of projects and
innovation such as flying robots, weather stations, for enhancing day to day
routine, autonomous vehicles, self-driving cars and much more…
Barometric Pressure
Barometric pressure is the pressure happened by load/weight of air pushing
down to the ground, moreover it’s called as atmospheric pressure, lets
visualize a cluster of air rising from the ground’s surface to the top of the sky.
The air in the sky has huge mass, therefore gravity causes the weight of which
cluster of air to exert pressure on the surface.

Atmospheric pressure or Barometric pressure consequences from the mass of


the air on the ground. This pressure is around 1 kg per square centimeter on
the sea level. Here are numerous units to indicate the barometric pressure
which can be simply transformed to other one. The SI unit of measuring the
pressure is Pascal (Pa).
Photoresistor Sensor (LDR)
The Light Dependent Resistor (LDR) is an electronic element that resistivity
is differ from how much of lights received (the resistance will be declined
while light is passing), Light dependent resistors also known as
Photoresistors, are light sensitive sensors most frequently used to point out
the presence or absence of luminance source, or used to estimate the intensity
of light.

At the dark night time, LDR resistance is extremely high, the LDR is made-up
of cadmium sulphide tape, a semiconductor. Once the photons passing
through tapes, electrons can travel via the semiconductor. The significant role
of Photoresistor is estimate the intensity of lights (most commonly used in
street lights, night camera, detection systems , and automatic security lights).
The following are some of the advantages or benefits of photoresistor
devices:
In addition to being a replacement for variable resistance, it is also a
light-dependent device.
When light falls on it, its resistance drops, whereas in the dark, its
resistance increases.
There are many different types and sizes of photo resistors available at a
low cost.
They are very energy efficient and need very little voltage and power to
operate.
Simpler circuits can be created with it. Due to its bidirectional nature, all
directions can be connected with it.
Applications of LDR
Low-cost and simple, light-dependent resistors can be readily used in a
variety of applications. Devices such as these are used wherever it is
necessary to know when light is present or absent. Light-responsive resistors
are often used in lighting and light intensity meters, as well as burglar alarm
circuits, as they act as light sensors. To provide more insight into this
concept, here is an explanation of a live lighting project that uses LDR to
conserve energy
Digital Thermal Sensor - Humidity Sensor
There are several types of temperature sensors compatible with Arduino, as
you can see in the following image.

Measuring the temperature level with the Arduino is much straightforward


and extremely useful task, here we can see widespread of temperature sensor
module available in the market with specific characteristic that we can able
to utilize in our upcoming projects, in this section, we can get through a
several types of low-cost temperature sensors, this is Arduino friendly and
also compatible with mini development module (Such as ESP32 or ESP8266
NodeMCU).

DHT11 Temperature and Humidity Sensor


DHT11 is frequently used temperature sensor in Arduino platform, this will
helpful for estimation of moisture content available in the surrounding air,
nitrogen, argon or pure gas. The amount of temperature or moisture in air
harmful for several physical, biological and chemical processes. In
manufacturing enterprise applications, humidity may disturb the commercial
rate of the products, safety, and health of the workers. Subsequently,
in semiconductor field and control system manufacturing unit have estimation
humidity or temperature is crucial one. There are two kind of Humidity
sensors specific on their measurement units. They are listed here,
1. Relative humidity sensor and
2. Absolute humidity sensor.
DHT11 is a Relative humidity sensor, which is used measure the atmospheric
air, this module also utilized as a thermistor and a capacitive sensor. DHT11
is developed as a sensor element and as a module the only dissimilarity of
this sensor and module is the power-on LED and a pull-up resistor.
The DHT11 is a unique digital temperature sensor which measures
temperature and relative humidity. This module includes a chip which can
convert analog to digital as well as spit out a digital signal through the
temperature and humidity. DHT11 is compatible with most electronic board
and extremely simple to use at all microcontroller development board, as
well as the Arduino.
DHT22
The DHT22 temperature sensor which most likely to the previous one. It
similarly used to determine the humidity and temperature and the pin
configuration is also same. DHT22 is considerably high cost, nevertheless it
is reputed for its accuracy and it also have a broader humidity and
temperature measurement range.
LM35DZ, LM335, LM34
The LM35DZ is a linear temperature sensor module which approaches
commonly measured in Celsius. The temperature in Celsius is directly
proportional to the analog output: 10mV for each amounts Celsius increase in
temperature. This temperature sensor is most related with the LM34 (only
difference is standardized in Fahrenheit), and by the LM335 (standardized in
Kelvin).
BMP180
BMP180 is an atmospheric or barometric pressure sensor, as we know
already in the previous section, correspondingly it can read temperature and
much helpful for any weather station project.
TMP36
The TMP36 is one of the analog temperature sensors, it shows an analog
output which is relative to the atmospheric temperature, and it’s more or less
same like LM35.
LM75
The LM75 sensor is a unique digital temperature sensor with an incorporated
Sigma-Delta analog to digital converter with an I2C communication. Which
functioning through I2C communication that means this can interface with the
Arduino using the SDA and SCL pins.
BME280
The BME280 is a special type of atmospheric sensor which can be measures
humidity and temperature. BME280 Temperature sensor could be interface
with I2C or Serial Peripheral Interface communication protocol and the
BME280 sensor might be powered by 3.3 or 5V.
DS18B20
The DS18B20 is a single cable digital temperature sensor, which means it
just wants single data line with GND to interface with the Arduino. Every
DS18B20 sensor module has an exclusive 64-bit serial code, this permits
you can connect several sensors to the same data wire. Consequently, you can
read temperature from various sensors with just single Arduino digital pin.
Waterproof DS18B20
The DS18B20 is correspondingly comes with waterproof model (Refer the
DS18B20 manual), the single cable attached in the DS18B20 are secure
with PVC waterproof coating that is supreme when you want to estimate the
temperature of fluid, or provided the project wants to be exposed to liquid.
Application of Temperature and Humidity Sensor
1. Estimating moisture and temperature values in air conditioning systems,
boiler, and other air circulation devices.
2. Meteorological department often utilized this module to forecast weather
situations.
3. The temperature sensor is utilized for precautionary measurement in
houses and wherever persons are troubled by humidity.
4. Utilize this module for detecting the amount of humidity level in safety
measure application such as workplaces, museums, greenhouses and
manufacturing units.
Rotary Encoder Module
A rotary encoder is a unique kind of position sensor element that is utilized
for measuring an angular position of a rotating shaft, rotary encoder be able
to produce an electrical signal, for both analog and digital, based on the
rotational movement.
Rotary Encoders are the advanced Digital Equivalent of the variable-
resister and are more sophisticated than a variable-resister. It can be able to
freely adjust or rotate until it reaches maximum level without end, breaks
when a variable-resister to be able to rotate specific on 3/4 of the complete
circle.
Variable Resister are good in situations somewhere you want to get the
particular position of the knob. Though, rotary encoders are best in situations
somewhere you want to get the adjustment in position instead of the
particular position.
Rotary encoders are utilized in a widespread of application such as
mechanical systems, with manufacturing controls system, photographic
lenses, autonomous robotics, and PCs input devices such as optical
mechanical mouse and trackballs, spinning radar devices, and controlled
stress rheometers.
MQ-2 LPG Smoke Gas Sensor

The MQ-2 Gas sensor module can be detecting fire, smoke or gasses such as
LPG, Hydrogen, Propane, Alcohol, Methane and also CO. The module series
of this Gas sensor including with Digital Pin that makes possible this sensor
to work even with no microcontroller support and that portable to use while
we need to senses one specific gas.
At what time it comes to detecting the gas in ppm the analog pin must be
used, the analog pin also TTL logic driven and operating at 5V and therefore
it can be utilized with most reputed development board.
Accordingly in case you may searching for a sensor module to sensitive for
fire or plethora of gasses then this sensor could be more suitable for you.
Application of MQ-2 LPG Smoke Gas Sensor
MQ2 sensor module is used as a gas leakage alarm in Hospitals,
Industries, and Home), and also used in air quality monitoring projects.
It is right choice for sensing such as LPG, H2, Propane, Alcohol, and
also CH4. Because of its great sensitivity and quick reaction, this
sensitivity might be taken as early as possible. This sensor also used to
identify the presence of gases in the atmospheric air.
To detect toxic or explosive gasses and measure gas concentration,
these devices are commonly used. Manufacturing facilities use gas
sensors for detecting gas leaks as well as detecting smoke and carbon
monoxide in homes. Various types of gas sensors have different sizes
(portable or fixed), ranges, and sensing abilities.
SW-420 Motion Sensor or Vibration Sensor
The vibration sensor based on the SW-420 Motion Sensor and LM393
Comparator that is utilized to sense the motion activity and vibrations, the
sensitivity of vibration can be modify with a built-in variable-resister. If the
time of without vibration or motion, the sensor will send command to the
logic as LOW and once the motion or vibration is detected, the sensor will
trigger to the logic as HIGH.
Vibration sensor has 3 pins there are VCC, Digital Output, and GND, The
Digital Output pin is associated to the output pin of LM393 comparator IC. It
extremely simple to interface Vibration sensor module with the any
development microcontroller board like Arduino, Raspberry Pi and
ESP8266.
The wiring connection of an Arduino with this SW-420 module is very
straightforward, connect the DO pin of the sensor to any digital pin of
Arduino and connect VCC and GND pins to 5V and GND pins of an Arduino
board.
Applications of Vibration Sensor Module
Shocks triggering
Earthquake alarm
Theft alarm
Smart car
Motorcycle alarm
Passive Buzzer Module
A buzzer is an electronic device which can be produce unique tones, most
commonly utilized to provide loud response for the people. Buzzers are
utilized in various kind of application such as emergency alarm clocks,
calculator, keypads, hobby toys and several household appliances.
The Passive Buzzer Sensor contains a passive piezoelectric element. Which
can be produce sounds from 1.5 to 2.5 kHz with changing it ON and OFF at a
several frequencies whichever using PWM or Delays. On the other hand, an
active buzzer sensor which have an on-board oscillating crystal, therefore
that will make a unique sound once power-on. Nevertheless, a passive
buzzer doesn’t have this function, subsequently there is no beep-sound once
given DC signal; as an alternative you should be apply square-waves which
frequency is among 2K and 5K to operate it. The active buzzer sensor is
slightly more expensive than the passive buzzer sensor, for the reason that,
because it has numerous on-board oscillating circuits.
The buzzer module is extremely easy to wire up to the Arduino. Connect the
left pin of the module to the pin that will drive it and the right pin of the
module to Arduino GND. The module is driven by pin 8 in the circuit below.
Several pins of the module are not connected, including the middle one.
Application
Passive Buzzer Sensor is used in various kind of application such as
Detecting obstacles and gives warning, Burglar Alarm, Blind stick and also
used as a Door knock alerts system.
Speed Sensor Module LM393
A speed sensor is similar to the Tachometer which is utilized to find out the
speed of a spinning object such as fan, motor and a propeller, here is there
are several kinds of Speed Sensor available in the market such as Hall-
effect, Eddy Current, and Magneto-resistive Speed Sensor, etc.
Speed sensor is also known as Hall Effect Sensor, so that for estimate the
speed of any spinning devices with Arduino, we may use LM393 Speed
sensor. Speed Sensor Module consist of an IR Light Sensor combined with
LM393 Voltage Comparator IC.
Applications
LM393 Speed sensor most frequently used in Robotics.
Motor Drivers
Printers, Scanners, Copiers
Contactless Switching,
Measuring Speed, and used to find out an RPM.
This Infrared Hall Effect sensor with the Voltage comparator LM393, we be
able to measuring the speed of spinning or rotation of the wheels in most of
the robotic car projects. Provided we place a circle gear which rotates
linked to our wheel. This will likewise be utilized as an optical switch.
The simple working of this module is as follows; when anything is crossed
between the sensor slots, that generates a digital pulse on the D0 pin. This
pulse drives from 0V to 5V and is a digital TTL (Transistor-transistor logic)
signal, finally, we be able to read this pulse with an Arduino.
Relay Module

A relay is primarily a switch that is activated by an electromagnet. The


electromagnet just needs a little power to become triggered, and that we can
send command from the Arduino and after once it triggered, this will pull the
connection to produce the high voltage circuit, Relay module is an
electrically activated switch, which can be switch on or off, allowing the
current get through or not, and might be operated with minimal voltages as
5V given by the Arduino pins.
The following relay module has two channels (for those two blue cubes), and
here we can see as of single to multichannel available in the market, there are
one, two, four and eight channels. Most of the Relay module could be
powered with 5V, which is applicable to work with an Arduino. Here are
other relay modules which are powered with 3.3V that is perfect for
NodeMCU, ESP8266, ESP32 and other Development board.
The Arduino compatible relay consist of six pins: three pins on front side and
another 3 pins on different side. In the lower side, here is there are 3 pins
that are 5V, ground and signal. Accordingly, we can interface these pins with
the microcontroller. Whereas, on the other hand here are normally open
(NO), NC (Normally close) and C (Common), there are the output pins
supporting for 5V relay. Consequently, we be able to associate the output
device.
Most of the Arduino friendly relay module can be used in two states which
are
1. Normally open state (NO)
2. Normally closed state (NC)
Normally open (NO)
In the normally open state, the beginning output of the relay should be
minimal once that will be power on. Here in state, the common and the
normally open pins will be used.
Normally closed state (NC)
In the normally closed state, the beginning output of the relay should be
maximum once that will be power on. Here in state, the common and the
normally close pins will be used.
The purpose of relays is to isolate low voltage circuits from high voltage
circuits. Multi-circuit controllers are used to control multiple circuits.
Automatically changeover can also be done with them. Controlling a heavy
electrical load is done by microprocessors using relays
In real-world applications, relays are utilized in many areas. For instance, a
cooling system could be an example. When the temperature in the room
changes, the temperature-controlled cooling system will have to be able to
switch the fan on or off accordingly. Thermometers are electronic devices
with sensors inside them.
HC- SR501 Pyroelectric Infrared Sensor (PIR)

HC-SR501 is a modern motion detection module that is based on Infrared


Technology, which is utilize an IR signal for sensing the object, which is
include an autonomous control module, likewise having the functions of great
sensitivity and reliability. This module consists of an auto-detection control
modules, wherever we required to achieve motion. Pyroelectric IR Sensor is
used in construction projects and industrials for security purposes.
Why use Pyroelectric IR Sensor, and Its Future
HC-SR501 is also known as PIR (Passive Infrared) motion sensing
module. Which is applicable for sensing the moving objects ,
specifically for the animals and human.
This kind of sensor can be included as an element of a system which
can repeatedly performs a task or alerts a human motion in that
region.
This module is made-up of an essential component of security, energy
efficiency, automatic light control, house automation and many other
valuable systems.
PIR Sensor module also comprise time delay alteration and trigger
selection that give permission for fine tuning with your various
projects
Every single living thing with a temperature directly above Absolute
Zero (0 Kelvin / -273.15 °C), which can produce heat energy in the
form of IR radiations.
When a heat body alive can emit more radiation. Human body
functioning on a same pattern and emits Infrared radiation via heat
energy.
A superior lens known as called Fresnel lens that focuses the IR
Radiation onto the pyroelectric sensor.
HC-SR-501 sensor module is intended to senses these types of IR
radiation from living objects.
Why PIR sensor to be extremely so popular because of main causes,
is the fact that Pyroelectric IR Sensor is a most versatile which is
much proficient all on its own way.
By using PIR Module with other microcontroller like ESP8266,
NodeMCU, and Raspberry Pi, you be able to develop upon its
flexibility even more.
Accelerometer Module

Before enter into the topics, you ever wondered how your mobile phone
knows up from down! that is one of the interesting features of today’s
smartphone gadgets, now a days majority of smart devices includes a
microchip called Accelerometer, which is built-in to the motherboard that
make senses once you tilt it from right to left and up and down. That’s how
your smart gadgets immediately realizes while to change the screen position
from landscape to portrait.

What is Acceleration?
The revolutionary scientist Isaac Newton well-defined in his 2nd law of
motion o r law of force, acceleration by connecting it to mass and force.
The acceleration is nothing but, the rate of change of velocity with respect to
time, It have both magnitude and direction accordingly acceleration is comes
under vector quantity. Which is the 2nd derivative of spot with respect to
time or it is the 1st derivative of velocity with respect to time.
Here is the Examples of some real-time day to day life application of an
acceleration:
1. While the vehicle is speeding up, and while the vehicle is slows
down
2. When the vehicle turning at the bend is for e.g. of an acceleration for
the reason that the direction is fluctuating. When the vehicle turning
will be fast, the acceleration will be greater.
3. When you free fall form the bridge.
Force = Mass x Acceleration or (F = ma.)
Acceleration of an object is related on the mass of the object and the how
much of force applied.
Acceleration = Force / Mass
This means that, acceleration is the amount of force we want to change each
unit of mass.
Accelerometer is an electromechanical module that involved the
processes both electrical and mechanical that identify the force of
acceleration by reason of gravity in g unit.
The Accelerometer determining the acceleration laterally X, Y and Z
axes and gives output of an analog voltage relational to the acceleration
laterally these 3 axes.
ADXL335 Module is most commonly used in the applications of tilt
sensing.
Many developments board like Arduino be able to process these voltages
by transforming them to digital signals via ADC.
Accelerometer sensor module are broadly utilized in low power, cost
sensitive, tilt sensing and motion detection projects such as Smartphone’s
gadgets, Gaming control systems Joysticks, Image, Video stabilization on
gimbals cameras, Sports Fitness Gadgets & healthcare devices and Disk
drive protection.
At the heart of the ADXL335 sensors is tiny in size, less power three axis
MEMS (Micro Electro Mechanical System) accelerometer beginning Analog
Devices through tremendously less noise. The module has overall detection
range of ±3 g, which can be identifying the static acceleration caused by
gravity in tilt-sensing projects, along with dynamic acceleration resulting
from motion, shock or vibration.
This module functioning on voltage among 1.8V to 3.6V DC (3.3V ideal),
and usually its takes just 350µA of current. Nevertheless, a built-in 3.3V
regulator perform it a special choice for handling on 5V developments board
like Arduino and Raspberry Pi.

The breadboard friendly ADXL335 sensor module breaks out every single
pin of the accelerometer to a 6-pin, 0.1″ pitch header. This contains three
analog outputs for X, Y and Z axis estimation, there are two self-test pin and
a supply pin that make you to clarify works of the sensor in the finishing
projects.
Arduino Joystick Module
The joystick is more or less same function with two variable-resister
(potentiometer) connected together, one for the horizontal movement (X-
axis), and another one is vertical movement (Y-axis) variable-resistances are
nothing but potentiometers and, in a technique, they react as a sensors module
they deliver us with varying voltage relating on their spinning.
Mostly commonly the joysticks are utilized for gaming industries, aviation
sectors and military applications.

This Joystick controller module is an excellent input device for controlling


stepper, servos motors, used as a video game joystick, and remote-control
robotics applications. The Joystick have both digital (DO) and analog (AO)
output options.
Piezo buzzer Sensor

Have you interested to make some tones with Arduino? Possibly a basic
sound for an alarm, perhaps a beep to aware you after a particular input
threshold level is achieved, or it could be to run and play the Super Mario
Bro music to perform your young mind.
If any kind of sounds required for your projects, you may discover
the simplest, fastest and probably the cost efficient way to generate your
desired sounds with the tone() function and piezoelectric buzzer with your
Arduino microcontroller.
Here is the two kind of piezo buzzers which are usually existing in the
market. The one is present like a basic buzzer, once we give power source,
that will produce a Nonstop Beeeeeeppp .... tones, another type known as a
portable buzzer that appearance slightly bigger than traditional one and it
will make a sound like “Beep. Beep. Beep.” Why sound happening…
Because of the internal oscillating circuit can perform there within.
However, the first one is much often broadly utilized for the reason that, that
can be personalized with help of customized circuits to easily compatible in
our projects.
The buzzer is generally related with a switching circuit to turn ON or turn
OFF, most of the buzzers required time and interval. We can just operate the
buzzer with help of DC voltage ranging from 3V to 12V, and A basic 9V
battery may be used, but then that is optional to usage a regulated +5V or else
+6V DC power source.
Applications of Buzzer
Most of the buzzers are audio signaling device which is utilized in
various kind of application such as timer circuits, alarms and tone
generating devices,
Somewhere the people have to be alarmed about their project, and
utilized in application like automobile electronics, communication
devices, portable devices, because of its compact in size
Water Flow Sensor
Powerful water management system take place in delivering water according
to the actual necessity, and therefore assessing water level is play a vital role
in aquatic management systems. Here are several methods to measure flow of
water, and various kind of water flow meters utilized to estimate the amount
of water-flow in pipelines, but these kinds of sensors available in the market
are too expensive. Here, we only see the concepts for design & development
of cheap water flow meters, with the support of easily accessible and cost-
efficient sensor module for estimation the Flow of water.
YF-S201 Hall-Effect Water Flow Sensor

Precise water flow estimation is a vital step for both in circumstances of


qualitative and cost-effective points of view. Water Flow meter is a standard
sophisticated sensor module for estimate water flow, and this is simple to
make a water flow controlling system, which utilizing the famous YF-S201
water flow sensor.
This sensor fixed in the pipe with the water line as well as includes a
pinwheel module to estimate how amount of water have passed over it. Here
is an advanced magnetic Hall Effect Water Flow Sensor which produce
outputs an electrical signal by each revolution. The “YF-S201 Hall Effect
Water Flow Sensor” consist of three wires: First one is Red/VCC (5-24V
DC Input voltage), second one is Yellow/OUT (Pulse Output) and third one
is Black/GND (0V). By counting the electrical pulses or signals from the
output of the YF-S201 module, we can simply estimate the flow of water
level (in litre/hour – L/hr) with a right conversion technique.
Magnetic flux leakage is used to determine magnetic fields, or to inspect
materials (such as pipes or tubing) using hall probes as magnetometers.
Devices that produce the hall effect produce a very low signal level and
therefore require amplification.
Arduino Color Sensor

Arduino Compatible TCS3200/230 color sensor module can detect color and
intensity of the light using photodiodes. This color sensor module converts
data from the photo-detector into a square wave by through the light to
frequency converter.
The frequency of the square waves is directly related to the intensity of light.
At that moment the Arduino will process the square waves then show us the
RGB color’s values as an output. Accordingly, we can see the working
diagram on interfacing controller with RGB Color Sensor TCS230 shown
upcoming section.
Here we can utilize widespread of projects with color sensors module such
as organize or separate a product by its color, Enhancing printer color,
quality control systems and etc. Theoretically speaking, figments of our
imagination is colors. When we see a green apple, which means that, it can
reflect that specific wavelength (~550 nm for Green) of the EM Spectrum
(EM - Electromagnetic).
This Electromagnetic wave is absorbed by the human eye and proportional
on some biochemical reaction, consequently our brain says that specific
wavelength is green color.
Optical Fingerprint Sensor
There are different kind of fingerprint sensors available in the market, from
capacitive fingerprint technology utilized in recent smartphones, to optical
fingerprint sensors frequently utilized in access control projects like smart
attendance. In this lesson, we will learn about optical fingerprint sensor.
Fig. R305 Optical Fingerprint Sensor-Scanner
The Optical fingerprint sensor module is an extremely portable device. It
come from embedded with an advanced DSP unit which stands for Digital
Signal Processing unit, that is utilized to processing the input images of
fingers captured and find out a match detect or not.
Once the fingerprint module acquired a fresh image, that is extracted and the
characteristic features are separated. The memory board of the module is
looking for a fingerprint with corresponding patterns and the consequence of
that period is sent to the Arduino board through serial communication. This
all process is finished within a second. The sensor module has the storage
ability up-to thousand fingerprints model with its memory and its training
accuracy rate is more than 99.8% which makes it more protected!
The Fingerprint reader is one of the safe and greatest technique to detect and
identify the original person, as we know already which every fingerprint is
unique even similar twins do not have unique fingerprints patterns. For
utilizing this we can develop and fulfil most safety needs. To add multiple
fingerprint authentication in Arduino like development board projects
application, also we can able to develop this multipurpose optical fingerprint
scanner-sensor (R305), which is make possible fingerprint sensing and
authentication is super simple.
By utilizing this fingerprint sensor module, we be able to develop project
like Biometric verification and Access control or smart attendance related
security application easily. This optical fingerprint sensor module includes
high powered AS601 Digital Signal Processing chip form Synochip which
perform the task such as feature extraction, image rendering, processing, and
searching. This also consist of TTL serial out consequently, we can link to
any Arduino and Raspberry pi board or system. The DSP processor has
built-in FLASH memory that can able to collect up to 120 fingerprints.
Heart Rate or Pulse Sensor
The Heart Rate Sensor is a plug-and-play pulse sensor for Arduino. Heart
rate sensor is used to measure the electrical activity of heart such as
electrical pulse. That can be utilized as a portable device and smart fitness
gadgets by athletes, students, performers, working people, and game and
mobile developers those who need to simply integrate a real time pulse-rate
information into their healthcare projects and many applications. Principle
which is an incorporated optical amplifying unit and noise removing unit in
the circuit module. Fastener the Heart Sensor to your tin ear or fingertip and
connect it into your Microcontroller like a Arduino and Raspberry Pi.

This Pulse rate sensor is pretty straightforward to use and activate it. Place
or hold your finger on top of the sensor and that can sense the electrical pulse
of heart is nothing but heartbeat by calculating the change in light from the
development of capillary blood vessels.
Capacitive Touch Sensor

Capacitive touch sensors will be utilized as a replacement for of push


buttons. The benefit is we don’t necessary to apply force therefore we can
just press a button. Similarly, we may activate a switch with no touching a
capacitive sensor, obviously without touching it. Now a days we all using
Touch screen gadgets and this technology is becoming famous progressively.
You could be to interact with this day by day and every hour. Every
smartphone these days has a touch screen or touch sensor.
In capacitive touch sensor when we bring human body nearby to the sensor
module a capacitance or electrical flux is produced between the Human body
and capacitive sensor. We assume the tip of finger and sensor body perform
well, correspondingly the plates of the capacitor and a charge is created
among the plates. This electrical flux or charge is chosen by the capacitive
sensor module and this interpreted as a pressing button. For example, when
we bring our finger back from the sensor plate the electrical flux or
capacitance is lost and the circuit may break.
TTP223 Capacitive Touch Module IC is the best and well-known Arduino
capacitive touch sensor available in the market. The corresponding circuit of
the touch sensor module is specified in the below diagram. In the circuit of
the TTP223 below, once we move our fingertip close to the touch plate, our
finger and touch plate can be produced electrical pulse or capacitor like
effects. This novel capacitor is in parallel to capacitor C1. Remember
capacitor in parallel is enhancing capacitance. Consequently, the capacitance
increases and an electrical flux is induced in the capacitor. This
electromagnetic induction is chosen by the sensor such like pressing a button.

Note: We don’t need touch our fingertip to touch pad. Capacitor can be
produced by attractive our finger closed the touch plate. Subsequently the
distance wanted to form capacitor is in Nano meters so typically we touch
our finger to the touch plate.
Arduino Bluetooth Module HC-05 or HC-06
You ever assumed monitoring any of your electronic devices and smart
gadgets with your smartphone? How about an autonomous robot or many
other electronic appliances? Wouldn't it be simple to control it with your
smartphone? Never mind, here is a cool sensor module for communicating an
Android smartphone with Arduino through Bluetooth HC-05!
How Does It Work?
There are 3 Essential parts to this project. First one is Bluetooth supported
smartphone, an Arduino and a HC05 Bluetooth Module.

HC-05 or 06 functioning on serial communication. The Android application


is intended to transmitting serial data to the Arduino board, HC05 Bluetooth
module once a switch is pressed on the app. The Bluetooth module at the
side receives the information and transmit it to the Arduino over the TX pin
of the Bluetooth module (associated to RX pin of Arduino). Once the sketch
is uploaded to the Arduino microcontroller verify the acknowledged
information and relates it. If the acknowledged information is 1, the LED
turns ON. The LED turns OFF once the acknowledged information is 0. You
can open the serial monitor and be able to see the acknowledged information
while connecting.
Arduino GPS Module (NEO-6M)
GPS stands for Global Positioning System this is a satellite-based location
identification system which includes at least 24 satellites. GPS can able to
function in all types of climatic situations, wherever in the world, GPS can
work 24*7, we can utilize it with no maintenance fees, no installation and
setup charges.
How GPS works
We all are known already; GPS is kind of satellites which spinning the Earth
double times a day in a specific orbit. Each satellite be able to send a unique
signal and orbital parameters which permit GPS system to decode and
calculate the exact places of the satellite
When your location has been identified, the GPS devices can calculate
additional data, such as:
Speed
Distance to destination
Bearing
Trip dist.
Trajectory.
What's the signal?
Global Positioning System satellites can send minimum of two little
power radio signals. The signals travel by line of sight, which is
nothing-but that will travel via clouds, plastic and glass however
would not suffer from most solid things, like houses, tower and hills.
Nevertheless, the latest receivers are more sensitive and generally it
be able to track through building as well.
There are 3 different kinds of data existing in a GPS signal
1. Pseudorandom code is an I.D. code used to identify which satellite is
sending data. The Pseudo Random signal is much complex which is
exactly similar to the random electrical noise.
2. Therefore, the name came up as "Pseudo-Random." Consequently,
we can see which satellites we are getting data from on our system's
satellite page.
3. Ephemeris information is wanted to estimate a satellite's location
and gives essential data regarding a status and health of a satellite,
such as date and time.
4. Almanac data is representing that the GPS receiver where each GPS
satellite device could be at any time all over the day and indicate the
orbital data for that GPS device and many other satellites in the
system.
5. Most of the satellite should be communicating the almanac
information for every satellite, almanac information contains a group
of parameters for every satellite which might be utilized to estimate
that approximate position in orbit.
NEO-6M GPS Chip

NEO-6M GPS chip is the heart of the GPS module is from u-blox. That be
able to track more than 22 satellites on up to 50 channels and it can attains
the industry’s peak level of sensitivity, Such as For -161 dB level of tracking,
it will consuming simply 45mA source current. The u-blox 6 locating
machine correspondingly claims a Time-To-First-Fix (TTFF) of less than 1
second. Power Save Mode (PSM) is one of the greatest features that the chip
provides. PSM is permits a decrease in device power consumption through
selectively switching portions of the receiver ON and OFF. This will
intensely cut the energy consumption of the device to just at 11mA building it
appropriate for energy sensitive use cases, such as Fitness gadgets comes
with built-in GPS. The essential data pins of NEO-6M GPS chip are
fragmented out to a "0.1″ field headers. This comprises the pins mandatory
for transmission through a Arduino microcontroller over UART.
Note: - The GPS module and NEO-6M GPS chip can accept the baud rate
from 4800bps to 230400bps with default baud of 9600.

RFID
What is an RFID reader?
RFID is stands for Radio Frequency Identification, which utilizes mini-
RFID module for recognition and tracking purposes. An RFID tagging
device contains the label itself, a read/write technique, and a host system
use cases for data gathering, data processing, and data transmission.

In layman's words an RFID utilizes the electromagnetic fields to send


information through minimal distances. RFID is beneficial to recognise
people, to make possible transactions, etc…
We can utilize a Radio Frequency ID to open a door. For example,
individual person with the unique code and right data on his RFID tag is
acceptable to enter. An RFID system uses a tag linked to the data to be
recognized, in this use cases we have an electromagnetic tag and a
keychain. Tag has his own unique identification (UID).
RFID tags are pretty universal in our society that the average person perhaps
meetings them day-to-day with no understanding it. Did you go to the library
or bookstore today? The book you bought was possibly registered with RFID
technology. Have you visited foreign in recent times? The authority can trace
journey information with RFID chips in passports. Have you ever had
suffering for searching a missing pet? Perhaps you should consider taking an
RFID chip embedded in pet strap to support track her next time she once
missed!
Application of RFID
Identification
Product Tracking
Bookstores and Libraries
Toll Gate Transaction
Shipping and Logistics
By providing a low cost, powerful, and reliable technique to gather,
accumulation and storage of information, RFID offers limitless opportunities
for present-day and future use.
Turbidity Sensor
The Arduino based turbidity sensor module can sense water quality by
calculating the level of turbidity. It can sense deferred particles in river or
any kind of water resource by determining the light transmittance and
scattering rate that variations by the amount of TSS (Total Suspended Solids)
in aquatic Level. Once the TTS (Turbidity Threshold Sampling) Level
increases, simultaneously the water turbidity level will increase.
This Turbidity sensor module both have digital and analog signal outputs. We
can choose the function which is based on to the Microcontroller Unit
(MCU), by way of threshold is variable in digital signal method.
Turbidity sensors utilized in wide range of application such as estimation of
water excellence in Ponds, Rivers, Wastewater, Watercourses, and used to
identification the overflow of water, sediment transportation study, control
instrumentation and research laboratory projects.
Fig. Turbidity Sensor Pinout
The significance Arduino turbidity sensor sense water standard by estimating
the amount of turbidity, or the opacity. It used to sense suspended particles in
liquid through light for calculating the light spread and sprinkling rate that
variations with the level of total suspended solids (TSS) in liquid. As we
knew already the TTS level is increases, the water turbidity level will
increase.
Load cell Module
A load cell is an application of strain measurements associated to estimation
of weight. A certain level of mass is given to a strain gauge, subsequently the
gauge to strain a minimal level and production an electrical energy relative
to the given load. This connection between strain and electrical energy is
utilized in various use cases where estimation of mass is significant. Load
cells are freely available in the market, for the reason that it’s linear
characteristics, cost efficiency, and their simplicity user interface.

HX711 is an Analog -to-Digital Converter (ADC) for weigh scales comes


with built-in preamplifier. This 24-bit ADC chip is known as the HX711,
which produce the minor effects in strain gauge from the load cell into 24-bit
changes in electrical energy or voltage (Arduino 0-5V).
HX711 is precisely intended for weight scales Arduino and such electronic
projects. These kind of load cells that generally calculate weight deliver
electrical outputs in millivolts. These results are much challenging to handle
straightly by controllers, consequently we be able to utilize HX711 IC which
obtain these electrical signals and deliver standard numerical data that might
be utilized by a microcontroller, and consequently the chip has included
preamplifier precisely to handle these low voltages.
PH Sensor Module
Arduino compatible analog pH sensor module is precisely intended to
estimate the pH of the liquid and measure the alkalinity, or acidity. PH
Sensor Module is most frequently utilizing in several kind of real-time use
cases, such as environmentally friendly water testing, aquaculture, and
aquaponics.
The pH Sensor looks like a glass tube generally made from a glass material
contains a built-in tip known as “Glass membrane”, which is include a buffer
solution liquid of known pH (usually pH = 7). PH electrode structure
validate surroundings with the continuous binding of Hydrogen ions on the
existing of the glass tubes and glass membrane. Once the electrode probe is
dipped into the liquid to be tested, H+ ions in the test liquid to start replacing
with other positively electrified ions on the glass tubes or membrane, that can
be generates an electrochemical potential through the glass membrane that
is served to the electronic amplifier chip that calculate the voltage difference
between both electrodes and converts it to pH units . The variance between
these voltage differences can measure the pH value according to the Nernst
equation.

Fig . Analog pH Sensor Module SEN0161 Interfacing with Arduino


The pH is a level which determine the alkalinity or acidity of the Liquid.
This is also known as H+ ion concentration index. The pH is a scale of H+
ion movement in liquid or any solution. The pH has a widespread range of
application such as in agriculture, chemistry and medicine. Generally, the pH
level is a digit between 0-14. Based on the thermodynamic standard
conditions;
1. pH<7 , that means the liquid is acidic ;
2. pH>7 , that means the liquid is alkaline ;
3. pH=7 , that means the liquid is neutral.
Pressure Sensor or Force Sensitive Resister (FSR)

In recent years, a force sensitive resistor (FSR) has become an indispensable


sensor which is utilized in a wide range of industrial applications.
Nowadays we can see these sensors in handheld gaming devices, mobile
phones, and other electronic instruments like electronic drums. These sensors
can be easily used and are great for detecting pressure.

How does an FSR work?


Pressure applied to the sensing area determines how much resistance an FSR
has. When you apply more pressure, the less resistance there will be. There
is quite a large resistance range: greater than 10MΩ (at no pressure) to ~ 200
Ω (maximal pressure). The range of force that can be sensed by FSRs is
nearly around 100g to 10 kg.
Basic construction
There are two membranes and one spacer adhesive in an FSR. An air gap
separates the conducting membranes when no pressure is applied. The
membrane contains two traces between the tail and the sensing area (rather
round part). It's impossible to touch these traces as they are woven together,
but not touching one another, consequently a conductive ink is coated on the
other membrane. Pressing on the sensor shorts the ink between the two
traces, the resistance of which is dependent upon the pressure applied.

Force sensing resistors are used in various fields such as foot pronation
systems, automotive sensors, electronic keyboards and controls, biomedical
devices, as well as musical instruments, as well as mobile electronics and
wireless communications.
Flex Sensor

A flex sensor is a different type of unique sensor that determines the amount
of deformation or bending. Materials like carbon or plastic can be utilized in
designing the sensor. The carbon surface is attached to a plastic strip. If you
turn this strip away, the sensor’s resistance will change. Therefore, it is also
termed a bend sensor. Since its varying resistance directly correlates to the
magnitude of the rotation, the bend sensor can also be employed as a
goniometer.

Most of the time, this sensor is mounted to the exterior, and you can adjust the
resistance by adjusting the exterior. It is used by Nintendo in its power
gloves, door sensors, robot whisker sensors, this also the key component in
making alert stuffed animals.

Analog resistors are what are called Flex sensors. Variable analog voltage
dividers are made with these resistors. There are carbon resistive elements
inside the flex sensor, surrounded by a thin flexible substrate. Increased
carbon content means a reduction in resistance. With a substrate bent, the
sensor makes resistance which is relational to the radius of the bend.
Flexible sensors are thin and flexible, which allows them to achieve high
form factors. A sensor, as shown in Figure, produces a resistance output
inversely proportional to the bend radius of the substrate, Consequently More
resistance will be given by a smaller radius.

Flex-sensors are used for the following applications.


Physical Therapy
Healthcare Instruments
Robotics motion
Virtual Motion (Video Games)
A computer's peripheral devices
Musical Instruments

Summary
We have discussed the basics of electronic components in this chapter, the
components you need to start with Arduino, and different types of Arduino
Sensors and Modules. In the next chapter, we will explore the basics of
Arduino programming and how to get started with Arduino programming
CHAPTER 3
ARDUINO PROGRAMMING

Introduction
A convenient, easy way to learn and use Arduino programming reference for
understanding the basic Arduino commands and syntax can be found in this
Chapter. Take it easy and keep things simple, some things have been left out
that makes it a secondary reference. This is best used alongside other books,
classes, websites, or workshops. Since then, the Arduino maker community
has refocused attention on standalone use and, for example, excludes the use
of arrays or more complex forms of serial communication. Starting with a
description of Arduino's C derived programming language, the language's
syntax and usage will be illustrated throughout this chapter with code
fragments and some examples. An appendix includes many functions of the
core library and sample schematics and starter programs. Where possible,
this format complements O'Sullivan and Lgoe’s Physical Computing.
Arduino code is written in C++ and adds some special methods and
functions, which will be discussed later. Human-readable programming
languages include C++. The Arduino code file is compiled into machine
language after being processed into a sketch (as it is called in Arduino
parlance), which is a very simple hardware programming language. A sketch
should be uploaded on an Arduino board after it has been written in the
Arduino IDE.
Downloading and installing the Arduino IDE is the first step in programming
the Arduino board. Linux, Mac OS X, and Windows are all supported by the
open-source Arduino IDE. From the Arduino website, download the
software (depending on your operating system) and follow the installation
instructions.
Arduino programs follow a pretty straightforward structure. There are at
least two blocks in an Arduino program, The preparation process and the
execution of the plan The following statements are enclosed in curly braces
in each block:
Structure of an Arduino Code:

Bare minimum code


void setup () {
// put your setup code here, to run once:
}
void loop () {
// put your main code here, to run repeatedly:
}

setup: The Arduino uses it only when powered on or when it's reset. It
works in the same way as initializing variables and pin modes.
loop: Until the device is powered off, loop functions will run continuously.
In this section, the logic of the program is defined. Microcontroller
programming follows a similar pattern to while (1).
Arduino Data Types
Arduino C, a variable of data type int uses 2 bytes of information. When a
sketch uses int, it tends to use it almost everywhere, unless it is very memory
hungry. For tiny integer values or for Boolean values, even a single byte
value could be used.
Table 1-1 Includes a complete list of available data types.

Analog to Digital Conversion


What is analog?
It has a continuous voltage range (not just 0 V or 5 V)
Why convert to digital?
We have a microcontroller that can only read digital input.
Converting Analog Value to Digital
Quantization the signal

ADC in Arduino
There are 6 ADC pins on the Arduino Uno board.
Digital to analog converter with 10-bit resolution
That means input voltages between 0 and 5 volts will be converted
into integer values between 0 and 1024.
Reading/Writing Analog Values
analogRead(A0); // Th e pin A0 is used to read the analog value.
analogWrite(2,128);
Reading/writing digital values
digitalWrite(13, LOW); // this will select the output voltage on pin
13 , 0V
digitalWrite(13, HIGH); // It will select the output voltage on pin
13 , 5V
int buttonState = digitalRead(2); // Reads pin 2 values from the
buttonState
PinMode
The pinMode function on the Arduino lets you choose an input and
output pin.
pinMode(13, OUTPUT); // pin 13 becomes an output pin.
pinMode(13, INPUT); // pin 13 becomes an input pin.
ARDUINO PROGRAMMING BASICS
Structure
Arduino's basic structure isn't too complicated and works in two parts.
Blocks of statements are enclosed between these two required parts, or
functions.
void setup()
{
statements;
}
void loop()
{
statements;
}

Where setup() is the preparation, loop() is the execution. Both functions are
required for the program to work.
At the very entry level of the program, the setup function has to follow the
statement of any variables. A function that appears in the entire program runs
only one time, and is utilized to initialize serial communication or set the
pinMode.
Next comes a loop function, which contains the program to be run
instantaneously, it reads Inputs, triggered outputs and much more. In most
Arduino programs, this function is at the heart of the program.
setup()
When your program starts, setup() is called once. The pin mode is used to
start a serial connection or initialize pin modes. This type of statement must
be included, even if they will not be executed.
void setup()
{
pinMode(pin, OUTPUT); // sets the 'pin' as output
}

loop()
When naming the setup() function, the loop() function does specifically what
its name recommends, and loops sequentially, enabling the code to modify,
respond, and control the Arduino microcontroller.
void loop()
{
digitalWrite(pin, HIGH); // turns ‘pin’ on
delay(1000) ; // pauses for one second
digitalWrite(pin, LOW); // turns 'pin' off
delay(1000) ; // pauses for one second
}

functions
A Function is a block of code, wherever a function is called, a number of
statements are executed. In an earlier lecture, we talked about the functions
void set-up() and void loop() and others built-in will be explained later.
It is possible to write custom functions to simplify repetitive tasks and
minimize clutter in code. The first step in declaring functions is specifying
the type of function.
For example, ‘int’ represents an integer type function. A function's return type
would be void, if it returns no value. Name the function after type and
include any parameters that will be passed to it in parenthesis.
type functionName( parameters)
{
statements;
}
You can read the delay value from the potentiometer by using the function
delayVal(). A local variable v is declared, then one of the potentiometer
values is presented, The range for this number is 0-1023. Finally, it returns
this value back to the main program by dividing by 4 for an additional value
between 0 and 255.

int delayVal()
{
int v; // create temporary variable '‘v'
v= analogRead(pot) ; // read potentiometer value
v /= 4; // converts Q-1023 to 9-255
return v; // return final value
}

{} Curly braces
It is distinguished from "curly brackets" by its curly appearance, the void
loop() function and for and if statements, and may contain blocks which are
used to declare the beginning and end of function blocks and statement
blocks.

type function()
{
statements;
}

{There must be a closing curly brace after an opening curly brace}, As a


result of this, the braces are said to be balanced. Cryptic is often caused by
unbalanced braces, often impenetrable compiler errors occur in a large
program that are difficult to find.
An Arduino ecosystem has a feature to check whether curly braces are
balanced. The logical companion of a brace is highlighted if you choose it, or
if you click the entry point quickly following a brace.
; Semicolon
A semicolon must be utilized to separate sections of a program and to end a
statement. For loop elements are also separated by semicolons. The integer
13 is declared for variable 'x'.
Note: The compiler will generate an error if you forget to end a line with a
semicolon. A semicolon may or may not be missing, making the error text
somewhat obvious. It's always important to check for missing semicolons,
near the line where the compiler complained, in response to an impenetrable
or seemingly illogical compiler error.
/*...*/ block comments
Multi-line comments, also known as block comments, or parts of text that are
ignored by the sketch, a large text description is used to help others
understand a piece of code or comments. The syntex will start with /* and
finish with */ and it can span numerous rows.

\*Do not forget to add the closing comment to the enclosed block comment –
it has to be balanced!*/

The program ignores comments, so they do not take up any memory, It's okay
to use them to “comment out” portions of code or to use them to fix bugs.
Note: A single-line comment may be enclosed in a block comment, but two
block comments are not allowed.
// line comments
Each line of code in a comment starts with // followed by the subsequent line
of code. They don't take up any memory, just like block comments.
// Such comments can be put in a single line.
In many cases, a single-line comment will be placed after a valid statement
to provide more info about what the statement accomplishes or to remind the
reader.
Variables
Variables are used by the program to name and store a mathematical value.
As their name implies, variables are numbers that can be changed
continuously as opposed to constants whose value stays the same. It is
necessary to declare a variable and optionally assign a value to it with the
goal of storing the value. An analog input pin is connected to a variable
named as input Variable, and its value is assigned to that variable:

int inputVariable = 0; // declares a variable and


// assigns value of 0
inputVariable = analogRead(2); // set variable to value of
// analog pin 2

‘inputVariable’ is the variable itself. On the first line, it is declared to


include an integer, or int. Upon passing the 2nd line (sequence 1), the
variable is set to value at pin 2 of the analog system. The value of pin 2 can
now be accessed from anywhere in the code.
You can test the value of a variable once it has been assigned, or reassigned,
based on specific circumstances, or its value can be directly used. Three
ways to use variables are demonstrated in the following example, In the
following code, input variable is tested for whether it is below 100 and if
true value 100 is assigned to input variable, and set the delay to a minimum
of 100 based on inputVariable:

if (inputVariable < 100) // If the variable is below 100, it will tested.


{
inputVariable = 100; // the value 100 is assigned if true
}
delay(inputVariable) ; // uses variable as delay

Note: A variable's name should describe what it does, making it more


readable. It is important for the programmer to name variables like tilt
Sensors and pushbuttons to make it easier for anyone reading the code to
understand what the variables represent. On the other hand, variable names
like var or value do little to make the code easier to read and are only
utilized here as examples. Anything in the Arduino language can be named a
variable, as long as it is not already an Arduino keyword.
Variable declaration
An integer, long, float, or float-like variable must first be declared in order
to be used, specifying an initial value and optionally setting a name. One set
of arithmetic functions and general assignments is all that is needed in order
to change the value of the variable. Here, inputVariable is declared to be an
integer, or int, and its original value is zero. This is named as a simplified
assignment.

int inputVariable = 0;

There are numerous places in which variables can be declared across the
program, and which part of the program uses the variable depends on where
the variable definition is located.

Variable scope
In a program, variables can be declared before void setup(), locally in
functions, and occasionally in for loops within statement blocks. It is
determined where the variable is declared, which calculates its scope, which
determines the program's ability to utilize the variable.

Any function in a program can see and use a global variable. An initialization
variable is declared before the setup() function.

Typically, a local variable is one created inside of a function or within a for


loop. The function declaration only allows it to be accessed and used within
the context in which it was declared. So, you can have different values for
the same variable if they are in various sections of similar program.
Simplifying the program and reducing the potential for programming errors
can be achieved by making sure only one function has access to its variables.

Various types of variables are declared and their visibility is demonstrated


by the following example:

int value; // ‘value' is visible


// to any function
void setup()
{
// no setup needed
}
void loop()
{
for (int i=0; i<20;) // ‘i' is only visible
{ // inside the for-loop
i++;
}
float f; // ‘f' is only visible
} // inside loop

byte
Bytes represent 8-bit numerical values without decimal points. They can
range from 0 to 255.

byte someVariable = 180; // declares 'someVariable'


// as a byte type

int
The integer data type is utilized to store numbers without decimal places and
stores 16-bit data with a range of 32,767 to -32,768.

int someVariable = 1500; // declares 'someVariable'


// as an integer type

Note : As long as a variable isn't forced past its maximum or minimum value
due to an assignment or comparison it will roll over. As an example, if x =
32767 and later x is added to by the addition of 1, then x will equal -32,768.
long
Integers stored in 32-bit format, without decimal points, are of extended size
datatype, with a range between 2,147,483,647 to -2,147,483,648.

long someVariable = 90000; // declares 'someVariable'


// as a long type

float
A type of floating-point number that has a decimal point. Integers have
greater resolution than floating point numbers which are stored as a 32-bit
value with a resolution of 3.4028235E+38 to -3.4028235E +38.

float someVariable = 3.14; // declares '‘someVariable'


// as a floating-point type

Note: It can be complicated to compare floating-point numbers, since they


are not accurate. In addition, floating point math performs calculations much
more slowly than integer math.

Arrays
Arrays are collections of data accessed by index numbers. Array values may
be accessed using the array name and index number. Arrays start at index
number 0, with the first value beginning at index number 0 in the array. To
utilize an array, you must declare it and possibly assign values to it.

int myArray[] = {valueQ, valuel, value2...}

Similarly, arrays can be declared by declaring the array type and size, and
later assigning values to an index position:

int myArray[5]; // declares integer array w/ 6 positions


myArray[3] = 10; // assigns the 4th index the value 10

Arrays are retrieved by assigning an index position and the array's variable.

x = myArray[3]; // x now equals 10

For loops also make use of array values in two-dimensional arrays, where
the index position and increment counter for each array value are the same.
Below is an example of flickering LEDs using an array, Within a for loop, the
counter reads the value contained at index spot 0 in the array flicker[], the
PWM pin 10 is set to 180, pauses for 200ms and the index position is moved
to the next position.
int ledPin = 10; // LED on pin 10

byte flicker[] = {180, 30, 255, 200, 10, 90, 150, 60};
// above array of 8

void setup() // different values


{
pinMode(ledPin, OUTPUT); // sets OUTPUT pin
}
void loop()
{
for(int i=0; i<7; i++) // loop equals number
{ // of values in array
analogWrite(ledPin, flicker[i]);
// write index value
delay(200); // pause 200ms
}
}

Arithmetic
These mathematical operations include addition, subtraction, multiplication,
and division. Two operands are returned as a product, difference,
sum(respectively) or quotient(respectively).

y = y + 3;
x = x - 7;
i = j * 6;
r = r / 5;
The operands of the operation are based on their data types. Therefore, the
result of 9 / 4 is 2 instead of 2.25 since 9 and 4 are not decimal numbers and
cannot be expressed as fractions. Additionally, if the result of the operation
exceeds the capacity of the data type, the result will overflow.
The larger type is used for the calculation if the operands are of different
types. The calculation will use floating point math if one of the numbers is of
the type float and the other of the type integer.
The variables selected for your calculations should have a large enough size
to hold the largest result. Understand when and how your variable will roll
over, in addition to knowing what happens in the opposite direction e.g. (0 -
1) OR (0 to - 32768). For fractions to be used in math, float variables are
preferable, but they are large and take a long time to compute.
Note: Convert a variable's type on the fly by using the cast operator,
(int)myFloat is an example. For example, 1 = (int) 3.6 will set i equal to 3

Compound Assignments

Combining two arithmetic operations into one variable Assignment is


compound assignments. For loops are generally used to create them as is
discussed later. The most common compound assignments include:

Examples include x *= 3 which would triple the value of x, which would


lead to a new value of x.

Comparison Operators

When a condition is true, if statements compare variables or constants to see


if they match. On the following pages, the referring to a predicate is utilized
to describe any of the following:
Logical operators

There are logical operators that are usually implemented to compare


expressions, and depending on the operator it will return TRUE or FALSE. If
statements are commonly used with three logical operators, AND, OR, and
NOT:

Constants
Several predefined constants are available in the Arduino programming
language. Constants are arranged into groups to simplify readability of the
programs.

True/false
Logic levels are defined by Boolean constants. Typically, TRUE is defined
as one while FALSE is easy to decipher as zero (zero) but can also be
anything other than zero. Therefore, in the Boolean sense, -1, 2, and -200 all
have the same definition of TRUE.

if (b = = TRUE);
{
doSomething;
}
High/low
When reading or writing to digital pins, these constants are utilized to define
pin levels as HIGH or LOW. HIGH is defined as logic level 1, ON, or 5
volts while LOW is logic level 0, OFF, or 0 volts.
digitalWrite(13, HIGH);

Input/output
The constants utilised to define a pin's mode will be either INPUT or
OUTPUT with the pinMode() function.

pinMode(13, OUTPUT);

if

if statements are used to determine if a condition has been attained, it


performs any statements inside the brackets if the statement is true, such as a
certain analog value being greater than a certain number. If false, the program
skips the statement. Here's what an if statement looks like:

if (someVariable ?? value)
{

doSomething;
}

Here, the variable someVariable is compared with another value, which may
be a variable or a constant. The statements inside brackets are run if the
condition inside the parentheses is true, A program taking care of the
brackets skips them if they are not present.
Note: Make sure you never accidentally use ‘=’. If (x=10), for example. x is
defined to the value 10 and thus is always true, even though technically it is
valid. It is better to instead use ‘==’, as in if (x==10), which simply checks
that the value x is the same as 10, Think of ‘=’ as “equals” opposed to ‘==’
being ‘is equal to”.

if... else

When used with if...else, a decision can be made either one way or the other.
In other words, if you needed to test digital inputs and perform one thing if
they were HIGH and another if they were LOW, you would write this way:

if (inputPin == HIGH)
{
doThingA;
}
else
{
doThingB;
}

if else tests can also be run before another if test, so that a number of tests
relating to the same thing can be run simultaneously. Moreover, one can have
a limitless number of these other branches. Although there are several
statements, only one set will be run according to the conditions:

if (inputPin < 500)


{
doThingA;
}
else if (inputPin >= 1000)
{
doThingB;
}
Else
{
doThingC;
}

Note: A conditional statement is a simple logic check that checks if the


statement's terms are true. In the first example, if (inputPin == HIGH), this
statement can take any valid C statement. If the input is indeed high, or +5v,
then if statement verifies only if the input is truly a high-level input.

for
For statements are used to repeat either a single statement or an array of
statements. The loop is typically terminated by using an increment counter.
For loop header consists of three parts that are divided by semicolons (;):

for (initialization; condition; expression)


{
doSomething;
}
Only one time is the local variable initialized, or the increment counter
initialized. A condition of the following is tested with each loop. The
following statements and expressions are performed if the conditions remain
true and the tests for the condition again. After a period of time, the loop
ends, indicating that the condition became false.
Below, the integer is initialized to 0 and the test is run to see if i is still
below 20. If so, then it is incremented by 1 and the enclosed statements are
executed:

Note: Some other computer languages include BASIC, but they offer
significantly less flexibility than for loops in C. Although semicolons are
required, any or all of the headers may be omitted. In addition, the statements
for the statement initialization, the condition, or the expression can have any
valid C statement that contains variables unrelated to each other. There may
be some solutions to rare programming problems with these unusual
statements.
while

While loops will continue to loop indefinitely until the argument within the
parenthesis turns false. Unless something changes the variable being tested,
the loop will never terminate. In your code, this can be internal, like an
incremented variable, or outside the code, like testing a sensor.

while (someVariable ?? value)


{
doSomething;
}
In the example below, ‘someVariable’ is tested to see if it is smaller than 200
and loops until ‘someVariable’ becomes greater than 200 and executes the
statements within the brackets.

while (someVariable < 200) // tests if less than 200


{
doSomething; // executes enclosed statements
someVariable++; // increments variable by 1
}

do... while

do loops work similarly to while loops as they are bottom-driven, except that
at the finish of the loop the condition is tested; therefore, the do loop will
always perform at least once.
do
{
doSomething;
} while (someVariable ?? value);

Following is an example where readSensors() is assigned to the variable ‘x’,


followed by a 50 millisecond delay, and then loops indefinitely until the
value of ‘x’ stops being less than 100:

do
{
x = readSensors(); // assigns the value of
// readSensors() to x
delay(50); // pauses 50 milliseconds
} while (x < 100); // loops if x is less than 100

pinMode(pin, mode)
Following is an example where readSensors() is assigned to the variable ‘x’,
followed by a 50 millisecond delay, and then loops indefinitely until the
value of ‘x’ stops being less than 100:

pinMode(pin, OUTPUT); // sets ‘pin’ to output

Inputs are default for Arduino digital pins, so pinMode() is not required to
declare them as inputs explicitly. Impedance state is said to exist on pins
designated as INPUTS.
The Atmega chip comes with 20KQ pull-up resistors which are easily
accessible from software. There is one way to gain access to these pull-up
resistors:

pinMode(pin, INPUT); // set ‘pin’ to input


digitalWrite(pin, HIGH); // turn on pullup resistors

Connectors such as switches are normally connected to pull-up resistors.


Here, you see that pin does not become an output, but merely the means by
which internal pull-ups are activated.
Those pins specified for OUTPUT are thought to contain low resistance and
provide a current of up to 40 mA (milliamps) to other instruments / circuits.
Neither current nor voltage are sufficient to run most relay, solenoid, or
motor devices.
The output pin on an Arduino can be damaged or destroyed or the whole
Atmega chip can be damaged and fried if they are short circuited or if they
receive too much current. A resistor of 4700 or 1KO can be connected in
series with the OUTPUT pin of a computer if it needs external connecting.
digitalRead(pin)
This method results in a HIGH or a LOW result from the value of a specified
digital pin. You can specify pins either as constants or variables (0-13).

value = digitalRead(Pin); // sets 'value' equal to


// the input pin

digitalWrite(pin, value)
Outputs the specified digital pin as either HIGH or LOW. Either a constant or
a variable can be used to define this pin.

digitalWrite (pin, HIGH); // sets 'pin' to high

Here's an example of an LED that's linked to a digital output that reads a


pushbutton connected to a digital input:

int led = 13; // connect LED to pin 13


int pin = 7; // connect pushbutton to pin 7
int value = 0; // Variable to store the read value
void setup()
{
pinMode(led, OUTPUT); // sets pin 13 as output
pinMode(pin, INPUT); // sets pin 7 as input
}
void loop()
{
value = digitalRead(pin); // sets ‘value’ equal to
// the input pin
digitalWrite(led, value); // sets ‘led' to the
} // button's value

analogRead(pin)
This function interprets the value from a 10-bit analog pin. These functions
only work on pins 0-5 in the analog input. There are a total of 1023 possible
integer values.

value = analogRead(pin); // sets ‘value’ equal to ‘pin’


Note: An analog pin is not required to be declared before it can be used as
an input or output; it can be used either way.

analogWrite(pin, value)

An output pin marked PWM is used to write a pseudo-analog value utilizing


hardware provided pulse width modulation (PWM). This function is
available by default on Arduinos with the ATmega168 chip beginning at
version 2.0. The ATmega8 chip used in older Arduinos only supports pins 9,
10, and 11. Variables and constants may be specified with values ranging
from 0-255.

analogWrite(pin, value); // writes ‘value' to analog ‘pin'

At 255, a steady 5-volt signal is produced at the specified pin while a value
of 0 generates a constant 0-volt output. For values in When the value is 0 to
255, the pin alternates quickly between 0 and 5 volts. The greater the value,
the fewer times the pin is HIGH (5 volts). The value 64, for example, will be
0 volts three quarters of the time, and 5 volts one quarter of the time; 128
volts equals 0 volts half the time and 255 volts the other half; and 192 volts
equals 0 volts one quarter of the time and 5 volts two-thirds of the time.
As the pin is considered to be hardware, it will continue to generate a wave
in the background until another analogWrite call (or another call to
digitalRead or digitalWrite on similar pin) is received.
Note: Unlike digital pins, analog pins do not need to be stated as INPUT or
OUTPUT beforehand.
This example outputs a PWM signal to a PWM pin when we read an analog
value from an analog input pin, convert the value by dividing it by 4, and
convert it back into an analog value.
int led = 10; // LED with 220 resistor on pin 10
int pin = 0; // potentiometer on analog pin 0
int value; // value for reading
void setup(){} // no setup needed
void loop()
{
value = analogRead(pin); // sets ‘value’ equal to ‘pin'
value /= 4; // converts 90-1023 to 0-255
analogWrite(led, value); // outputs PWM signal to led
}

delay(ms)
A time period of 1000 milliseconds will pause your program.

delay(1000) ; // waits for one second

millis()
The time within milliseconds since the current program began running on the
Arduino board as an unsigned long quantity.

value = millis(); // sets ‘value’ equal to millis()

Note: Within approximately 9 hours, this number will overflow and reset to
zero.

min(x, y)
This function finds the smaller number between two numbers of any
information kind and returns it.

value = min(value, 100); // sets 'value' to the smaller of


// ‘value’ or 100, ensuring that
// it never gets above 100.

max(x, y)
A function that returns the largest number from a set of data types.

value = max(value, 100); // sets ‘value’ to the Larger of


// ‘value’ or 100, ensuring that
// it is at least 100.
randomSeed(seed)
The random() function starts with the value, or seed, specified by random().

randomSeed( value) ; // sets ‘value’ as the random seed

The Arduino does not produce a truly random number, so randomSeed lets
you place variables, constants, and functions into the random function, in
order to increase the number of random numbers. Several different functions,
or seeds such as millis() or even analogRead() can be utilized in this function
to read an analog pin's electrical noise.

random(max)
random(min, max)

The random function executes pseudo-random computations based on the


input values and returns a result.

value = random(100, 200); // sets ‘value’ to a random


// number between 100-200

Note: You need to utilize this after you have utilized the randomSeed()
function.
Below is an example that creates a stochastic value between 0-255 and
outputs on a PWM pin a PVVM signal similar to that quantity.

int randNumber; // variable to store the random value


int led = 10; // LED with 220 resistor on pin 10

void setup() {} // no setup needed

void loop()
{
randomSeed(millis()); // sets millis() as seed
randNumber = random( 255); // random number from 0-255
analogWrite(led, randNumber); // outputs PWM signal
delay (500); // pauses for half a second
}

Serial.begin(rate)

Opens serial port and sets the baud rate for serial data transmission. The
typical baud rate for communicating with the computer is 9600 although other
speeds are supported.

void setup()
{
Serial.begin(9600); // opens serial port
} // sets data rate to 9600 bps

Note: You cannot use two digital pins at the same time when using serial
communication.

Serial.printin(data)
The printing commands include a carriage return and a line feed, followed by
printing data on the serial port. Printing data on the Serial Monitor is easier
with this command than the Serial.print() command.

Serial.println(analogValue); // sends the value of


// ‘analogValue'

Note: Please refer to the Arduino website to learn more about the
serial.printin() and serial.print() functions and their various permutations.
Below is a straightforward example transmitting information every 1 second
from analog pinO to the computer.
void setup()
{
Serial. begin(9600) ; // sets serial to 9600bps
}
void loop()
{
Serial.println(analogRead(0)); // sends analog value
delay(1000) ; // pauses for 1 second
}

Digital output

It simply turns something on or off using a simple ‘hello world’ program. In


this instance, an LED becomes visible by connecting pin13 to GND, which
blinks every second. Due to the Arduino's built-in resistor, it is possible to
omit the resistor on this pin.

Digital input

There are two possible states for this type of input: on or off. We're reading
from pin2 a simple switch or pushbutton. Input pin HIGH turns an LED on
when the switch is closed.
High current output

Controlling more than 40ma can sometimes be necessary with the Arduino.
Switching higher currents could be achieved by utilizing MOSFETs or
transistors. Using an instance, we can rapidly turn the MOSFET on and off
five times a second.
Note: On the schematic the diode is shown only as a protection to the motor.
But other eddy current devices would also be able to be utilized without the
diode.

PWM output

Pulse width modulation (PWM) can be used to reproduce analog signals by


pulsing the output. Dimming and brightening an LED could result in servo
motor control. A for loop is used to control the brightness and dimmer of an
LED slowly.

Potentiometer input

You can read values from 0-1024 using an analog potentiometer and an
analog-to-digital converter (ADC) pin on an Arduino. An LED’s blinking
rate can be controlled by adjusting the potentiometer in the following
example.

To connect the Arduino board, we connect three wires. Potentiometers have


two pairs of pins, one of which is connected to ground.
A second connector connects the 5 volts to the outer pin of the potentiometer.
Third, there is a potentiometer that goes from analog input 2 to the middle
pin.
Variable resistor input
Thermistors, thermistors, flex sensors and the like are all examples of
variable resistors. In this example, the analog value is read using a function
and the delay time is set using a delay function. LEDs can be dimmed by
adjusting their brightness.
Servo output
Motors used in hobby products are self-contained and also able to move in a
full circle. A pulse every 20ms is all that is needed. In this example, the
motor is moved from 10° -170° and then back again, using a servoPulse
function.
Using Libraries
You’ll find it helpful to only contain code that you’d actually use on the
board, since Arduinos have a small amount of memory. By using libraries,
this can be achieved. Libraries are used in Arduino, and by extension in C
programming in general.
The Arduino IDE contains a library that contains instructions on how to use
an LCD display. The program memory used here is approximately 1.5kB. If
you don't use this library, there is no point in including it. It is “included”
when required. A #include directive is used right at the start of your sketch
for this purpose. Using the Sketch | Import Library... menu option, you can
include the libraries installed by the Arduino IDE.
A significant collection of official libraries is included in the Arduino IDE,
including:
EEPROM for storing data in EEPROM memory
Ethernet For system programming
Firmata The serial transmission standard for Arduino to pc
LiquidCrystal For alphanumeric LCD exhibits
SD For reading and writing SD flash memory cards
Servo For directing servo motors
SPI The Arduino to peripheral transmission bus
Software Serial For serial communication utilizing nonserial pins
Stepper For handling stepper motors
WiFi For WiFi network access
Wire For I2C communication with peripherals
Some facilities are particular form of Arduino board:
Keyboard USB keyboard emulation (Leonardo, Due, and Micro)
Mouse USB mouse emulation (Leonardo, Due, and Micro)
Audio Audio playing utilities (Due only)
Schedule r For managing multiple execution threads (Due only)
USBHost USB peripherals (Due only)
Also, the Arduino community has contributed a vast number of libraries
that are available on the Internet. Ones that are extremely popular include
OneWire using the 1-wire bus interface, Dallas Semiconductor's range of
digital devices can be read.
Xbee For Wireless serial communication
GFX. A graphics library from Adafruit that plays efficiently on several
various types of displays
Capacitive Sensing For proximity detection
FFT Frequency analysis library
The official Arduino website has a lot of the latest collections (
http://arduino.cc/en/Reference/Libraries ). You can also find them on the
Internet. If you want to utilize these libraries, you must save them in your
Arduino Documents folder Libraries. Please download the libraries and save
them there. You must create the libraries folder if it does not already exist
before adding a library. The Arduino IDE needs to be exited and restarted in
order to recognize a library that has been installed.

Summary
It has been condensed very much in order to provide a condensed
explanation of Arduino. At https://www.arduino.cc/ , you can find free
Arduino tutorials that you can refer to if you want to learn more about the
Programming fundamentals. In the next chapter, we will get started with
Arduino projects. Learn by doing more than 30 projects, we hope it will give
you a fascinated experience.
CHAPTER 4
ARDUINO PROJECTS LEARN BY DOING
Project 1: Blink an LED
We will learn how to make an LED blink in this practical session
Components:
1 x Arduino UNO
1 x USB Cable
1 x 220Ω Resistor
1 x LED
1 x Breadboard
2 x Jumper Wires
Principle:
We are going to learn how to program Arduino's GPIO outputs at both high
and low levels, and make an LED linked to Arduino’s general-purpose input
(GPIO) flicker with a specified frequency.
What is the LED?
The LED stands for light emitting diode. Gallium arsenide and gallium
phosphide are the most common semiconductor materials in these devices.
There are two electrodes in the LED: one positive, the other negative.
Flashing red, blue, green, yellow and others, it only lights up when an
electric current pass through it. Light varies in colour depending on the
material it is made from. By using a lower value resistor, more current is
allowed to flow, so the LED is brighter.
With higher resistor values, the LED will become dimmer because of the
restriction in current flow. A majority of LEDs also have polarity, meaning
that they need to be connected in the right directionless have just about the
longest life span of any lighting solution when compared to traditional
lighting solutions. A fluorescent or metal halide light will last only two to
four times as long as a sodium vapor light.
Procedure

Step 1: Build the circuit as


below:

Pin definition
LED UNO R3
Long pin -> +5V
Short pin -> GND
Note: Digital signal port 13(D13) is connected to the longest LED on the
pin.
Step 2: Make an LED Blink Program using Arduino IDE.

Step 3: Compile the sketch and upload to the Arduino UNO board. A Big
Kudos. As a result, you can see the LED blinking.
Uploading the Program
Please connect your Arduino to your PC with the USB cable before
uploading code.
Select Tools→Board→ Identify your board in the Arduino menu by
looking for Arduino Uno. You can also find the Arduino Mega, Arduino's
smaller cousin, through this menu.

Please make sure that you are connecting to the correct serial port on your
board, The list of accessible serial ports can be found by selecting,
Tools→Serial Port→ comX, as soon as your Arduino is linked to a
Windows laptop, it will take the largest number port, such as COM 3 or
COM 15.
Click Verify the LED Blink Sketch will be checked
Click Upload Consequently, the program is sent to the Arduino
microcontroller board

Project 2: Interfacing with Keypad Module


Overview:
With the Arduino UNO R3 board, we will be able to read the keys pressed
by a user so that the board can communicate with that keyboard.
Components:
1 x Arduino Uno
1 x USB cable
1 x Membrane switch module
1 x Breadboard
Jumper wires
Principle
The keypad is present in everything from cell phones to microwaves
to door locks. There are practically thousands of them. Users can
feed them into tons of electronic devices.
Making very different types of commercial products requires the
knowledge of how to connect a keypad to microcontrollers like the
Arduino UNO.
Eventually, when all has been properly connected and programmed,
the signal will appear in your computer's Serial Monitor when you
press a key. The Serial Monitor shows every key press on the
computer. Further down the line, in another project, the circuit will
be connected to an LCD, from where results will be observed on the
screen. Let's start with just showing the key pressed on the pc right
now for simplicity's sake.

A matrix keypad will be the most appropriate type of keypad for


this project. There are far fewer output pins on this keypad than
there are keys, allowing it to have much less encoding. There are 16
keys on the matrix keyboard we are utilizing, but only 8 output pins
on the circuit. If you were to build a linear keyboard, you would
have to put 17 output pins on the board (one for each key and a
ground pin). Matrix encoding saves a lot of connections for the
keyboard since smaller pins need to be utilized to have the keypad
work. Because they require less wiring, they are less inefficient than
linear keypads.

Schematic:
The Arduino UNO board uses the digital output pins, D9-D2, when the pins
are connected to the pins. The first pin of the keypad is connected to D9, next
to D8, then to D7, fourth pin to D6, then to D5, next to D4, next to D2, and the
eighth pin to D2. These are the connections in a table.
There is also a code and wiring diagram for a 3X4 matrix keypad. For the
purpose of this article, I'll be utilizing a matrix membrane keypad. It's easy to
stick membrane style keypads to flat surfaces because they have an adhesive
backing. For people who like the telephone style keypad style, there are
thicker buttons as well. Using an Arduino, even an old telephone keypad can
be converted to work with the device.
Procedure:
Step 1: Build the circuit
Step 2: Program

/*****************************************************
Project 05 - Interfacing with Keypad Module
*****************************************************/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the Rows of the keypad
pin 8, 7, 6, 5 respectively
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the Columns of the keypad
pin 4, 3, 2, 1 respectively
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins,
colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey); // Send the pressed key value to the arduino serial
monitor
}
}

Step 3: Compile the program and upload to Arduino UNO board.


Summary
I know this is a very simple example, but I think you can see how easy it is to
input keypad data into an Arduino program. These inputs can be used for a
variety of different projects, such as:
Door lock
Input PWM
Alarm clock
Security lock
Well, that pretty much sums it up. Setting up a keypad isn't hard at all. By
modifying the code above a little and trying it out, you should be able to get
the keypad to work with most of the projects you'd want to use it for.

Project 3: Multiple tones with one Piezo Buzzer


Overview:
The purpose of this lesson is to teach you how to use a buzzer.
COMPONENTS
1 x Arduino UNO
1 x USB Cable
1 x Buzzer
1 x Breadboard
2 x Jumper Wires
Principles
To generate air vibrations, buzzers use PWM (pulse width modulation) to
generate audio. Changed appropriately, the vibration can produce different
sounds as long as the frequency is appropriate. The pulse of 523 Hz, for
instance, can be sent to produce Alto Do, the pulse of 587Hz can be used to
produce midrange Re, and the pulse of 659Hz can be used to produce mi.
Play a song with a buzzer.
The pulse output of analog Write () on the UNO R3 board is fixed (500 Hz),
so we should be careful not to use it to generate a pulse to the buzzer.
To use the tone() command, take over one of the Atmega's internal timers, set
the frequency to what you want, and then pulse one of the output pins with the
timer. It only allows you to play one note at a time since it only uses a single
timer. Sequentially playing notes on different pins is possible, however. This
can be accomplished by turning off the timer for one pin before proceeding to
the next.
Are you planning on making some noise with Arduino? We all have our teen
years, but maybe make the Super Mario Brothers soundtrack play to occupy
your minds (it's OK -- we've all been there).
No matter what your audible need, using the tone() function and piezo
speaker with your Arduino will likely be the easiest, quickest, and cheapest
way to make some noise.

Schematic:
Procedure:

Step 1:
Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/*********************************************************
File Name: Multiple Tones with One Piezo Buzzer
**********************************************************/
const int buzzer= 8;
void setup() {
pinMode (buzzer,OUTPUT);
}
void loop() {
tone(buzzer,1000);
delay(1000);
noTone(buzzer);
delay(1000);
}

Step 3: Compile the program and upload to Arduino UNO board.


TONE () FUNCTION HAS LIMITS YOU SHOULD KNOW
Tones () have some limitations, like everything else in life. You should be
aware of them. Here are some of the points we need to discuss:

When using pins 3 or 11, you can't simultaneously use tone() and
analogWrite(). Trying to use either of these in the same way results in wacky
results. Since the tone() function for pins 3 and 11 uses the same timer that
analogWrite() does, it's because it uses the same built-in timer. Just for the
sake of hearing the weird noises, it's well worth the effort.

Tones lower than 31 Hz cannot be generated. Tones with values 31 and


below can be passed to the tone() function, however, it does not necessarily
mean you will get a good representation of them.

Tone() cannot be used by two different pins simultaneously. Suppose you


have two piezo speakers connected to different pins. Playing both of them
simultaneously isn't possible. You have to turn one on, after which you have
to turn the other one on. Additionally, for the other pin to utilize the tone()
function, the previous pin's tone must be turned off by calling the noTone()
function.

Project 4: Arduino Flame Sensor


Overview:
We will be studying a flame sensor built with an Arduino board in this
project.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Flame Sensor
1 x Breadboard
Jumper wire
Principle:
The flame detector module on the KY-026 is interacting with a lighter or a
candle through its digital and analog interfaces. When the fire sensor detects
fire, a HIGH signal is sent to the Arduino (pin A0), lighting up the LED. The
detection threshold may be increased by turning the potentiometer
clockwise, or decreased by turning it counterclockwis e .
Industrial buildings and commercial buildings are very commonly equipped
with fire alarm systems. Sensors are usually contained in these devices, and
they continuously monitor for flames, gas, and fires in the building and trigger
an alarm if they are detected. IR flame sensors contain an IR photodiode
which is sensitive to IR light and is therefore one of the simplest ways of
detecting fire. In a fire, fire does not only produce heat and light, but also
emits infrared rays, yes, every burning flame emits some degree of infrared
light. Flame sensors detect this light, which cannot be seen by human eyes,
and inform microcontrollers such as Arduino that a fire has been detected.
A photodiode detects light, and an op-amp determines the sensitivity of the
flame sensor. It detects fire and sends a HIGH signal as soon as it is
detected. The Arduino reacts to the signals and activates the LED and buzzer
to provide alert.
Schematic:
Procedure:
Step 1 : Build the circuit
Step 2: Program
/*********************************************************
Project 9 Arduino Flame Sensor.ino Description:
Let, fire is detected by the sensor turning on the LED
**********************************************************/
const int sensorMin = 0; // sensor minimum
const int sensorMax = 1024; // sensor maximum
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorReading = analogRead(A0);
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
switch (range) {
case 0: // A fire closer than 1.5 feet away.
Serial.println("** Close Fire **");
break;
case 1: // A fire between 1-3 feet away.
Serial.println("** Distant Fire **");
break;
case 2: // No fire detected.
Serial.println("No Fire");
break;
}
delay(1); // delay between reads
}
Step 3 : Compile the program and upload to Arduino UNO board.
Applications of flame sensors
Detecting fire in Hydrogen stations
Monitors for burner combustion
Petroleum and natural gas pipelines
Production facilities for the automotive industry
Facilities related to nuclear energy
Keeping aircraft in hangars
Enclosures for turbines
Project 5: Interfacing with LCD 1602 Display
Overview:
This lesson shows you how to use an LCD1602 character display system on
the Arduino environment. Let's display "Hello World!" on the LCD1602 first.
Components
1 x Arduino UNO
1 x USB Cable
1 x potentiometer
1 x LCD (16 x 2) Display
1 x Breadboard
Jumper Wires
Principle
Displays like LCD1602 show characters. Microcontrollers have a parallel
interface, which means that they have to manipulate several interface pins
simultaneously to control the display. Three pins are present on the interface:
pins:
There is a register select RS pin on the LCD that governs where in the ram
you need to write data. The LCD's controller may look for instructions in
either the data register or an instruction register - what goes on the screen has
to be in the data register.
Read/Write pins are used to switch between reading mode and writing mode.
Write access to the register is enabled by an Enable pin. This card contains 8
data pins (D0-D7). When the pins are high or low, the data that is being
written to a register (or read), is represented by bits.
Additionally, there are three display pins (Vo, Bklt+ and Bklt-) as well as
power supply and LED backlight pins to power the LCD and control the
display contrast, respectively.
Display control involves putting data read from the data registers into the
display's instruction register, and then writing commands into the information
registers.
So that you don't have to know these low-level instructions, the Liquid
Crystal Library simplifies these tasks for you. Two modes of control are
available for the Hitachi LCDs: 4-bit and 8-bit. For text displays on the
screen, you can do most anything in 4-bit mode. The 8-bit mode requires 11
I/O pins. Potentiometers have two contacts and at least three terminals each,
making it possible to adjust the voltage divider. If only one terminal and the
wiper are used, the resistor behaves like a variable resistor.
Schematic:

Connection to 16x2 Character LCD with Arduino Uno


Now that we've got the LCD hooked up to the Arduino, let's get started
uploading code and sending data.
We'll show you how to wire up the LCD's 16 pins (total of 16 pins). It is
good to know that we do not need to connect all of these pins to the Arduino.
We know that the display contains 8 data lines carrying raw data. HD44780
LCDs are designed such that 4 data pins (4-bit mode) can be used to
communicate with them instead of 8 data pins (8-bit mode). We will save
four pins this way!
Therefore, we will be interacting with the LCD using 4-bit mode and only
need six pins to interface with it: RS, EN, D7, D6, D5 , and D4.
The LCD Display now needs to be connected to the Arduino. The LCD will
be connected to Arduino's digital pins #4-7 via four data pins (D4-D7). A
pin on the LCD will be connected to Enable on Arduino #2 and a pin on the
LCD will be connected to RS on Arduino #1.
You can see how everything is wired in the following diagram.
Once that's done, all you need to do is upload some code and the display will
start printing.
Procedure:

Step
1: Build the circuit as below
Step 2: Program: Open /Copy the code from the “CODE” Folder
/****************************************************
File name: 11 Interfacing with LCD 1602 Display.ino Description:
Let, LCD display print HELLO WORLD.
*****************************************************/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 6, 4);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}

Step 3: Compile the program and upload to Arduino UNO board.


The LCD16x2 has the following features
The LCD is mainly equipped with the following features.
Its operating voltage ranges from 4.7V to 5.3V
You can create 16 characters from each row in two rows.
There is no backlight and the consumption of current is 1mA
A 5 by 8-pixel box can be used to create any character
Alphabets and numbers are displayed on the alphanumeric LCDs
There are two modes for the display: 8-bit and 4-bit
You can choose between a blue or green backlight, several characters are
generated specifically for it

Project 6: HC-SR04 Ultrasonic Distance Sensor with Arduino


Overview:
This lesson explains the use of an ultrasonic distance sensor to measure
distance.
Component:
1 x Arduino UNO
1 x USB Cable
1 x Ultrasonic sensor
1 x Breadboard
Jumper wire
Principle:
It has the same functions as the GP2D12 module except it uses sound instead
of light. When an object passes in front of the sensor the HC-SR04 sends a
ping and measures the period between transmitting a signal and receiving a
response.
Our measurement techniques use sound to reach a maximum distance of 4
meters. There is a connector with four pins on the module, larger than
45x20x15mm. The module should be powered with five volts by two pins.
15 mA is the working current. Several pins serve different functions. The
first one is for triggering the measurements while the last one reads the result
of that measurement, the echo pin. HC-SR04's measurement angle is 15
degrees. There should be about one meter of beam at 4 meters distance.
Using 1m as the measuring point, this is 26cm, so remember this when
utilizing this information.
You must set the trigger pin to the high state for 10 seconds in order to create
an ultrasound. It is at the speed of sound that these pulses will travel to the
Echo Pin and be received there. Using this tool, you can display the time in
microseconds in which the sound wave traveled. In the case of an object 20
cm from the sensor and sound speed of 340 m/s, the sound wave will travel
approximately 588 microseconds. Due to the fact that a sound wave travels
forward and then bounces back, you will get twice the amount of echo from
an Echo pin.
As a result, the distance measured in cm is calculated by multiplying the
received travel time value by 0.034 and dividing it by 2 and converting it to
centimetres.
Schematic:
The HC-SR04 can be interfaced in a 3-wire mode
Three-wire mode requires only one connection to a single digital I/O pin on
the Arduino instead of two. The exceptional parallax ping))) sensor is one of
the many ultrasonic sensors that only work in 3-Wire Mode.
One I/O pin is used in both input and output modes in 3-Wire mode. Due to
the fact that inputs and outputs are never used simultaneously, this is
possible. Then we can use the Arduino connection for something else by
eliminating one of the I/O pin requirements. This feature is also useful when
dealing with chips such as the ATtiny85 which have limited I/O pins.
This is how you can connect the HC-SR04 sensor to the Arduino using 3-
Wire mode.
Clearly, you simply need to connect pin 9 of the Arduino to both the trigger
and echo. There is only one difference you need to make in the sketch: you
must define both the Trigger and Echo pin values on pin 9. Everything else in
the sketch is the same.
Procedure:
Step 1: Build the circuit

Step 2: Program
/**********************************************************
File name: 12 – HC-SR04 Project .ino Description:
Let, Distance measure with ultrasonic sensor.************************/
#include <HCSR04.h>
const int TriggerPin = 8; //Trig pin
const int EchoPin = 9; //Echo pin
long Duration = 0;
void setup() {
pinMode(TriggerPin,OUTPUT); // Trigger is an output pin
pinMode(EchoPin,INPUT); // Echo is an input pin
Serial.begin(9600); // Serial Output
}
void loop() {
digitalWrite(TriggerPin, LOW);
delayMicroseconds(2);
digitalWrite(TriggerPin, HIGH); // Trigger pin to HIGH
delayMicroseconds(10); // 10us high
digitalWrite(TriggerPin, LOW); // Trigger pin to HIGH
Duration = pulseIn(EchoPin,HIGH); // Waits for the echo pin to get high
long Distance_mm = Distance(Duration); // Use function to calculate the
distance
Serial.print("Distance = "); // Output to serial
Serial.print(Distance_mm);
Serial.println(" mm");
delay(1000); // Wait to do next measurement
}
long Distance(long time)
{
long DistanceCalc; // Calculation variable
DistanceCalc = ((time /2.9) / 2); // Actual calculation in mm
//DistanceCalc = time / 74 / 2; // Actual calculation in inches
return DistanceCalc; // return calculated value
}

Step 3: Compile the program and upload to Arduino UNO board.


Project 7: Touch Sensor Arduino Interface
Overview:

Here we made a touch sensor based on Arduino using


a coin.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Touch Sensor
1 x Breadboard
Jumper Wires
Principle
This device connects to your body through its own electrodes. Capacitances
of the circuit are changed when you touch the sensing pad. The output
changes states as a result of the capacitance change.
The first time I got this device, I thought it would frequently produce
unexpected results despite being functional.
It's possible I was wrong. The game seems to do whatever I expect it to do
after playing for a few hours. The following might do the trick if you are
looking for strong client input.
How to interface a touch sensor with an Arduino:
Our next step will be to interface the touch sensor with the Arduino. An
Arduino board will be required to control the onboard LED via a touch
sensor. In addition, three jumper wires are needed male to female. A
breadboard and three male-to-male jumper wires can also be used if you do
not have these jumper wires.
First you need to connect the jumper wires to the touch sensor PCB of the
touch sensor to begin. In fact, the touch sensor is a resistor. If you press on
the PCB, it will increase its resistance. The PCB detects this and sends a
HIGH signal to the Arduino when you touch the sensor. Our touch sensor can
now be plugged into the Arduino. Connecting red and black wires to 5V,
ground and pin 8, green wires to digital pin 8 constitutes the five-volt supply.
Now that our circuit is complete, we can move forward.
Schematic:
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/**********************************************************
Project 13: Touch Sensor Arduino Interface .ino
Description: Let, Touch sensor using.
**********************************************************/
#define sensorPin 2 // capactitive touch sensor - Arduino Digital pin D2
int ledPin = 13; // Output display LED (on board LED) - Arduino Digital pin
D13
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}
void loop() {
int senseValue = digitalRead(sensorPin);
if (senseValue == HIGH){
digitalWrite(ledPin, HIGH);
Serial.println("TOUCHED");
}
else{
digitalWrite(ledPin,LOW);
Serial.println("not touched");
}
delay(500);
}
Step 3: Compile the program and upload to Arduino UNO board.
Project 8: Relay Module interface with an Arduino
Overview:
We will take a look at relay modules using this lesson.
Components
1 x Arduino UNO
1 x USB Cable
1 x Breadboard
1 x Relay Module
Jumper wire
Principle
Relays are electrically operated switches. Other operating principles are
also used in solid-state relays, as well as electromagnets used in many
relays. Controlling a circuit with a relay is best suited where a low-power
signal is needed (with complete electrical isolation between one circuit and
its control, and one signal must control various circuits).
A relay was the first device used in wide-area telegraphy circuits as an
amplifier. This signal was repeated on another circuit after it came from one
circuit. Early computers performed logical operations with relays widely
used in telephone exchanges.
Often referred to as a contractor, these relays are capable of handling high-
powered loads such as electric motors. Instead of using moving parts,
semiconductors are used to switch power circuits on solid-state relays.
Electrical circuits are shielded from overload or defects by utilizing relays
with calibrated operating characteristics and sometimes multiple coils.
Digital instruments known as protective relays perform these functions in
modern electric power systems.
LEDs will be powered by a 3v battery. To connect the positive and negative
sides of the battery, we have connected the positive side to the com of each
relay, and the negative side to the NO of each led. By giving a voltage range
of 5 to 24V DC, you can also power the four relay modules externally.
Schematic
Procedure:
Step 1: Build the circuit
Step 2: Program
/****************************************************
Project 14: Relay Module with Arduino
****************************************************/
int relayPin = 3;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, LOW); // turn the relay on (Active LOW operation)
delay(2000); // wait for a second
digitalWrite(relayPin, HIGH); // turn the relay off by making the voltage
HIGH
delay(2000); // wait for a second
}

Step 3: Compile the program and upload to Arduino UNO board.


Relays are used primarily in places where only low-power signals are
suitable for controlling circuits. With the advent of computers, they were also
used for Boolean operations and other logic operations. In order to drive
electric motors and other high power relay applications, high power is
required. Relays of this type are known as contactors.
Applications for relays
Logical functions are accomplished by relay circuits. The logic they
provide is extremely important for safety.
As a time-delay function, relays are utilized. Their purpose is to time
the delay open and delay close of contacts.
The use of relays for controlling high voltage circuits is based on
signals delivered at low voltages. Similar to this, they are used in
high current circuits by using signals with low current.
They can be used as protective relays as well. This function allows
all faults to be detected and isolated during transmissions and
receptions.
Project 9: Control Servo Motor with Arduino
Overview:
There is only one way to rotate a servo motor, which is in turn a type of
geared motor. The Arduino UNO R3 board sends electric pulses to control it.
The servo is instructed to move to that position by these pulses. The three
conductors of the servo include the brown wire which is GND, the red one
which is VCC and the orange cable which is the signal wire.
About Servo Motor

There is a servo motor, which operates at angles between 0 and 180


degrees.
Microcontrollers control servo motors, which are only powered from a
microprocessor like the following: The Arduino/Genuino, The Raspberry
Pi, Micro:Bit
It has a DC motor that only consumes 35 milliamps. A potentiometer
allows it to determine which angle it is in as well as some gears.
Electrical pulses are sent through the control wires of servos in the form of
pulse width modulations (PWMs). Minimum pulse, maximum pulse, and
repetition rate are all specified. In general, servo motors have a maximum
turning circle of 180° in either direction. Neutral position refers to the servo
having equal rotational potential clockwise or counterclockwise. As the
motor receives a pulse via the control wire, it determines the position of the
shaft, and the rotor turns to that position based on the duration of the pulse, a
servo motor turns according to the length of the pulse it receives every 20
milliseconds (ms).
The motor will turn to the 90° position with a 1.5ms pulse. If the servo is
moved faster than 1.5ms, it moves in the counterclockwise direction toward
0o, and if the servo is moved faster than 1.5ms, it turns in the clockwise
direction toward 180o.
COMPONENTS:
1 x Arduino UNO
1 x USB Cable
1 x Servo Motor
1 x Breadboard
2 x Jumper Wires

Schematic
Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/*******************************************************
File name: 15 Control Servo Motor .ino Description:
Let, servo motor rotate
**********************************************************/
# include <Servo.h>
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(6);
}
void loop() {
for (pos = 0; pos <= 180; pos += 5) {
myservo.write(pos);
delay(15);
}
for (pos = 180; pos >= 0; pos -= 5) {
myservo.write(pos);
delay(15);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Project 10: Stepper Motor Control with Arduino

Overview:
In this lesson we will learn how to control a stepper motor, a stepper motor
is controlled by a stepper motor’s rotational speed through an analog input,
analog input 0. Various control pins are available for unipolar or bipolar
motors including pins 2, 3, 4, and 5.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Stepper Motor
1 x Motor Driver Module
1 x Battery
Jumper wires
Principle
Motors that are operated by a stepper controller require the use of a driver
module. In our case, the motor will not be able to run since the controller
module (Arduino) is not capable of providing enough current through its I/O
pins. A module such as ULN2003 will be utilized.
There are many different types of driver modules that are used as stepper
motors. The rating of each driver module depends on the type of motor used.
Here is a circuit diagram showing how an Arduino stepper motor controller
is implemented. In our setup, we used a Stepper motor 28BYJ-48 as well as
the ULN2003 Driver module. A digital pin 8,9,10 and 11 is used to engage
the four coils on the stepper motor. Powered by the Arduino's 5V pin, the
driver module powers the Arduino Board.
When you connect the steppe motor to a load with an external power supply,
the driver should be powered. The +5V rail of the Arduino Board was used
because it is just being used as a demonstration. Keep in mind that you
should always link the ground of the Arduino to the ground of the Diver
module.

Pin definition
Connecting 28BYJ-48 Stepper Motor and ULN2003 Driver to Arduino
The motor is now ready to be hooked up to our Arduino! We can
begin connecting it to our Arduino now!
The ULN2003 driver needs to be connected to the power supply.
A stepper motor can be powered directly from the Arduino. As the
motor might induce electrical noise onto the Arduino's power supply
lines, this is not recommended since it could cause damage to the
board.
You should therefore use a separate 5V power source for your
stepper motor.
Lastly, connect the ground of the power supply to the ground of the
Arduino. It is very important to establish a voltage reference that is
the same between the two.
Assemble the driver board by connecting pins IN1, IN2, IN3, and
IN4 to the Arduino digital pins 8, 9, and 10.
The motor cable from the stepper motor should then be connected
to the driver board.
Upon completion, the illustration below should look like what you
have done.
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/*********************************************************
File name: 16 stepper Motor Control .ino Description:
Let, Control stepper motor .
*********************************************************/
#include <Stepper.h>
#define STEPS 64
Stepper stepper(STEPS, 8, 9, 10, 11);
int previous = 0;
void setup() {
stepper.setSpeed(30);
}
void loop() {
int val = analogRead(0);
stepper.step(val - previous);
previous = val;
}
Step 3: The motor will rotate clockwise once the program is uploaded to the
Arduino UNO board. Motor speed is increased by increasing the
potentiometer value. You may notice the motor, which is subject to a time
delay, is insensitive to changes in the sensor value when it is running at low
speeds since setSpeed() extends the length of the delay between steps.
The applications of stepper motors
Used in 3D printing equipment, Textile machines.
Various printing presses are used, utilized in the gaming machines.
Machines used in medical imaging, and a small robotics system.
Machines for CNC milling, Typically, welding equipment is used.
There are some benefits associated with stepper motors.
A motion sensor is not required for stepper motors because of their
internal structure. A motor's position can be determined by simply
counting the steps it takes to move.
As well, stepper motors are pretty easy to control. Although the
motor requires a driver, it does not require complex calculations or
tuning. Most motors require less control effort than others. It is
possible to achieve high position precision with micro stepping, up
to approximately 0.007 degrees.
A stepping motor offers good torque, holds positions well, and has a
long lifespan.
Project 11: Interfacing Soil Moisture Sensor with an Arduino
Overview:
We will be studying soil moisture sensors in this project which have been
specially developed to identify how much moisture or water a soil includes.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Soil Moisture Sensor
Jumper Wires
Principle
Soil Moisture sensors are utilized to precisely measure how much moisture
the soil includes. Dielectric constants are measured using capacitance in soil.
As the soil transmits electricity, the dielectric constant can be thought of as
the ability to conduct electricity.
Increased water content of the soil increases the soil's water content.
Because of its higher dielectric constant than any other portion of soil, water
is used to measure moisture in soil sensors. The sensor detects the moisture
content in the soil by generating a voltage proportional to its dielectric
permittivity, which consequently determines how much water is available.

The most important thing for us to take care of plants and turf is to take care
of them regularly when we have a home garden or a backyard with turf.
Watering your lawn and plants with sprinklers is one of the more popular
options, but for the best results, go for manual watering.
You must consider the amount of soil moisture when designing an Automatic
Plant Watering System, in which the water supply is either sprinklers or drip
irrigations.
A Microcontroller and a Water Pump can be used to precisely control the
amount of water supplied to the garden by measuring the soil moisture. By
integrating Soil Moisture with Arduino, I will demonstrate how to monitor
the soil moisture of a small pot.

Schematic:
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE”
/**********************************************************
Project: 17. Soil Moisture Sensor .ino Description:
Let, Detect the amount of moisture or water soil contains.
*********************************************************/
const int hygrometer = A0; // Soil moisture sensor analog pin output at pin
A0 of Arduino
int value;
void setup() {
Serial.begin(9600);
}
void loop() {
value = analogRead(hygrometer); // Read analog value
value = constrain(value,400,1023); // Keep the ranges!
value = map(value,400,1023,100,0); // Map value : 400 will be 100 and
1023 will be 0
Serial.print("Soil humidity: ");
Serial.print(value);
Serial.println("%");
delay(1000); // Read every 1 sec
}
Step 3: Compile the program and upload to Arduino UNO board.
Project 12: Interfacing Sound Sensor Module with Arduino
Overview:
With this experiment, we will understand how to use a Sound Sensor module
with an Arduino.
Components:
1 x Arduino Uno
1 x USB Cable
1 x Sound sensor module
1 x Breadboard
Jumper wires
Principle:
There are two outputs that come from the Sound Sensor: AO, analog output,
and DO, real-time digital output, the threshold-sensitivity of the noise to be
achieved by potentiometer adjustment will be achieved when a certain
threshold is reached for the intensity of the sound.
PIN Configuration
KY-037 Arduino
A0 -
+ 5v
G GND
D0 Pin 2
This type of sound sensor is inexpensive, easy to interface with, and detects
sounds like voices, claps, or doorbells. These sensors can be used for a
variety of purposes, such as making your lights clap-activated or tracking
your pets when you're away.

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/*****************************************************
File name: 20 –Sound sensor module
*****************************************************/
const int ledPin = 13; //pin 13 built-in led
const int soundPin = 2; //sound sensor attach to A0
int threshold = 600; //Set minimum threshold for LED lit
void setup() {
pinMode(ledPin,OUTPUT);//set pin13 as OUTPUT
Serial.begin(9600); //initialize serial
}
void loop() {
int value = digitalRead(soundPin);//read the value of A0
Serial.println(value);//print the value
if(value > threshold) //if the value is greater than 600
{
digitalWrite(ledPin,HIGH);//turn on the led
delay(200);//delay 200ms
}
else
{
digitalWrite(ledPin,LOW);//turn off the led
}
delay(1000);
}
Step 3: Compile the program and upload to Arduino UNO board.
Project 13: Analog Joystick Module with Arduino
Overview:
This tutorial will demonstrate how to use an analog joystick module. Adding
some control to your projects is straightforward with analog joysticks.
Components:
1 x Arduino Uno
1 x USB cable
1 x Joystick Module
1 x Breadboard
Jumper wires
Principle
Joystick
This module has 5 prongs: Vcc, Ground, X, Y, Key. Its labels may differ from
yours. The module will depend on where you receive it from. With the
thumb stick, you can pull the left side of the control stick to push down, and
the right side of the control stick to push down. Furthermore, you can activate
a „press to select" button by pressing the joystick down (which is quite hard
on mine).
The data from the X/Y pins will be read using the Analog Arduino pins, and
the button will be read with a digital pin. If the joystick is pushed, it connects
to the ground, but it floats otherwise. Key and Select pins must be connected
via a pull-up resistor to Vcc in order to yield stable readings. Digital pins on
Arduino are equipped with built in resistors. The following schematic will
guide you through activating pull-up resistors on Arduino pins that are
designed as inputs.
In terms of analog joysticks, they are similar to two potentiometers connected
together, one for the vertical movement (Y-axis), and another for the
horizontal movement (X-axis). In addition to the joystick, it also has a Select
button. A controller like this can be very handy for retro gaming, robotic
control, and RC cars.
Schematic
Procedure:

Step
1: Build the circuit
Step 2: Program
/****************************************************
File name: 21 - Analog Joystick Module. No
Description: Let, Analog Joystick Module
***********************************************/
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = A0; // analog pin connected to X output
const int Y_pin = A1; // analog pin connected to Y output
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
Serial.begin(9600);
}
void loop() {
Serial.print("Switch: ");
Serial.print(digitalRead(SW_pin));
Serial.print("\n");
Serial.print("X-axis: ");
Serial.print(analogRead(X_pin));
Serial.print("\n");
Serial.print("Y-axis: ");
Serial.println(analogRead(Y_pin));
Serial.print("\n\n");
delay(500);
}
Step 3: Compile the program and upload to Arduino UNO board.
Application
A camera's pan/tilt can be controlled
Controls and input for the game, Robotics control
Input of Analog Parameters, and Often used in DIY projects
Game controllers come to mind when we hear the word "Joystick". There are
many applications of the joystick in electronics. They are commonly used in
DIY robotics projects and Arduino-based projects. Having an analog output,
we can use this module to feed in an analog input based on movement or
direction. Alternatively, it can be controlled with a movable camera.
Project 15: Interfacing DHT11 Sensor with Arduino
Overview:
This project will answer all your questions on how to receive humidity and
temperature data using the DHT11 sensor and then send it to Arduino Ultra.
Components
1 x Arduino UNO
1 x USB Cable
1 x DTH11 Temperature Sensor
1 x BreadBoard
Jumper Wires
Schematic:

Procedure:
Step 1: Build the circuit
This is the time when the Arduino IDE software should be running. Next, you
have to install the DHT Sensor library. This can be done via the Arduino
Library Manager:

Sketch→Include Library→Manage Libraries…

Look for the "DHT sensor library by Adafruit " within the " dht " search
field. Click "Install" or "Update" if you have an older version installed.

IMPORTANT: As of version 1.3.0 of the DHT library, the Adafruit_Sensor


library is also required. This is available under the Arduino Library
Manager.

Step 2: Program: Open /Copy the code from the “CODE” Folder
/**********************************************************
File name: 22 Interfacing DHT11 Sensor with Arduino .ino Description: Let,
Showing the temperature using DHT.
**********************************************************/
#include <SimpleDHT.h>
int pinDHT11 = 7;
SimpleDHT11 dht11;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("=================================");
Serial.println("Sample DHT11...");
byte temperature = 0;
byte humidity = 0;
byte data[40] = {0};
if (dht11.read(pinDHT11, &temperature, &humidity, data)) {
Serial.print("Read DHT11 failed");
return;
}
Serial.print("Sample RAW Bits: ");
for (int i = 0; i < 40; i++) {
Serial.print((int)data[i]);
if (i > 0 && ((i + 1) % 4) == 0) {
Serial.print(' ');
}
}
Serial.println("");
Serial.print ("Sample OK: ");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" %");
delay(1000);
}
Step 3: Compile the program and upload to Arduino UNO board.
Applications
The sensor is used for a wide range of applications, including the
measurement of humidity and temperature in HVAC systems. They can also
be used to predict weather conditions in weather stations. In homes where
humidity affects people, the humidity sensor provides a preventive measure.
The sensor is used for measuring humidity values in offices, cars, museums,
greenhouses, and industries as a safety measure.
This sensor gained popularity among hobbyists because of its small size and
high sampling rate. Besides the DHT11 sensor, there are some other sensors
that can be used instead, such as DHT22, AM2302, SHT71.
Project 15: One digit 7 Segment Displays with an Arduino

Overview
In this project, the control of the LEDs is the same as the LED experiment,
however, the experiment can record time.

Pin definition
Embedded systems and industrial applications using one-digit seven segment
displays commonly known beforehand the range of outputs that will be
displayed. 0-9 numbers, and a few characters, can be displayed on this 7-
segment display. The types of 7 segment displays differ, for example the
number of characters and digits they can display varies. Basic 7 segment
displays can display only one character or one digit, and they are essentially
single units. In multiplexed 7 segment displays, 2 digits, 3 digits, or 4 digits
are shown through the multiplexing of single unit displays. You can connect
your Arduino to a 7-segment display very easily! We'll begin the tutorial
now.
In regards to the number of characters the 7-segment display can display, it
has many limitations. On the market are displays that are much more
advanced than seven segment displays; they are capable of displaying nearly
every alphabetical character. Suppose, for example, that you have a 16*2
LCD – which can display almost any ASCII character. It makes you wonder
why there are still 7 segment displays available on the market today. There is
no doubt that 7 segment displays represent the most affordable option among
display devices available. A 7 segment display capable of displaying one
digit or one character is available for one tenth the price of a LCD module.
The rectangular plastic package contains one of the LEDs' connection pins
which led out from its positional segment. The LED pins are labelled "a"
through "g", with each LED representing one of the individual LEDs. Each
LED pin is connected to another LED pin, forming a common pin. When
Forward Biased in a specific order, some LED segments will brighten but
others will remain dim, thus showing the corresponding character on the
display.
Displays are generally classified according to their common pins. Pin
connections consist of two types: one pin with cathodes connected and
another with anodes connected, indicating Common Cathode (CC) and
Common Anode (CA). CA displays have all the anodes connected to the
cathodes, while CC displays have all the cathodes connected to the anodes.
Hardware required
Material Material Number
Diagram
1 digit LED 1
Segment
Displays
220/330Ω 1
resistor
USB Cable 1
UNO R3 1
Breadboard 1
Jumper wires few

Connection diagram
Note: Pay attention to the direction of digital tube Connection:
UNO SEG
R3
D3 -> C
D4 -> D
D5 -> E
D6 -> G
D7 -> F
D8 -> A
D9 -> B
GND -> COM
Program
// declaring an array of integers
int numbers[] = { 90, 150, 30 };
int a, b;

void setup() {
a = numbers[0] + numbers[1]; // Sets variable a to 240
b = numbers[1] + numbers[2]; // Sets variable b to 180
}

// different ways of declaring arrays of chars


char string1[15];
char string2[7] = {'h', 'e', 'l', 'l', 'o', '!'};
char string3[7] = {'h', 'e', 'l', 'l', 'o', '!', ''};
char string4[] = "hello there!";

int a = 10;

// allocates an array for holding 10 characters


// (last position is for holding the '' or NULL string terminator
char *string5 = new char[a+1];
...
// releases the memory space allocated for string5
delete [] string5;
Compile and upload
After uploading code, you can see the number on the digital tube increased
from 0 to 9. As you can see from the code given above, the Arduino code is
extremely simple and follows the beginners' approach. An array or other
advanced programming element can allow a program to be written in a
smaller number of lines. As you can see in the following lines, the pin names
for the segments have been assigned. Additionally, we have configured all
the outputs that we will be using. Counting 0-9 is accomplished with a for
loop, and switching between the relevant statements is achieved using a
switch statement.
Project 16: Interfacing Bluetooth module HC-05 with Arduino
Overview:
This project will help you understand the Arduino using the HC-05 Bluetooth
module.
Components:
1 x Arduino Uno
1 x USB Cable
1 x Bluetooth Module HC-05
1 x Breadboard
Jumper wires
Principle:
Bluetooth modules such as HC-05 (master/slave) allow Arduino to
communicate with other devices. Using it, the Arduino can connect to
smartphones, computers or other microcontrollers and exchange information
with them. With Bluetooth communication, you can control robots remotely,
view and store data remotely on your PC or smartphone inside your home,
for example.
PIN Configuration:
Key – Arduino Pin 9
Vcc – Arduino 5v
GND – Arduino GND
TXD – Arduino Pin 10
RXD – Arduino Pin 11
A Brief Introduction to Bluetooth Protocols and Communication
There are several wireless communication methods, such as NRF, ZigBee,
Wi-Fi, and Bluetooth. PAN communication with Bluetooth protocol; a
wireless communication method with a maximum data rate of 1 Mb/S,
working on 2.4 G frequency, at a distance of up to 100 meters is a prevalent
method of wireless communication.
The HC05 Bluetooth module, usually used in electronics projects, is a serial
communications Bluetooth module. The following are important
specifications for the Bluetooth module HC05: An internal antenna is
included with the device. Automatic connection to the last device is
available.
Bluetooth data transmission to Arduino
You can connect the HC05 module to a 5V voltage because it has an internal
3.3v regulator. The serial communication pins of the HC05 module operate at
3.3V, so we strongly recommend 3.3V voltage from the power supply.
Modules that receive 5V voltage may be damaged. A resistance division
circuit (5v to 3.3v) should be used between the Arduino TX and module RX
pins to prevent damage to the module. A blue and red LED on each board
blinks every 2 seconds when the master and slave are connected. When they
are not connected, only the blue light blinks every 2 seconds.
Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/**********************************************************
File name: 26 – Interfacing Bluetooth module HC-05 with Arduino Let,
Bluetooth module HC 05.
**********************************************************/
// This program shown how to control arduino from PC Via Bluetooth
// Connect ... // arduino>>bluetooth
// D11 >>> Rx // D10 >>> Tx
//Written By Mohannad Rawashdeh
//for http://www.genotronex.com/
// you will need arduino 1.0.1 or higher to run this sketch

#include <SoftwareSerial.h>// import the serial library


SoftwareSerial Genotronex(10, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer

void setup()
{
// put your setup code here, to run once:
Genotronex.begin(9600);
Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
pinMode(ledpin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Genotronex.available()) {
BluetoothData=Genotronex.read();
if(BluetoothData=='1') { // if number 1 pressed ....
digitalWrite(ledpin,1);
Genotronex.println("LED On D13 ON ! ");
}
if (BluetoothData=='0')
{ // if number 0 pressed ....
digitalWrite(ledpin,0);
Genotronex.println("LED On D13 Off ! ");
}}
delay(100); // prepare for next data ...
}
Step 3: Compile the program and upload to Arduino UNO board.
AT Commands
In general, typing the command AT+<command>? will prompt the saved
parameter (ex: AT+PSWD? will display the module PIN code). If you enter
AT+<command>=<Param>, you can set the parameter value(ex:
AT+PWSD=0000 to modify the PIN code to 0000).
Following is a list of AT commands:
If everything is setup correctly, enter AT in the serial monitor on the
Arduino IDE. If the communication was successful, it should show OK.
To change the component name, enter AT+NAME=<Param>. The
component should answer OK (Defaut HC-05, Ex: To modification the
name to BTM1 enter AT+NAME=BTM1).
To modify the PIN code, enter AT+PSWD=<Param> . The module should
answer OK(Default 1234 Ex: To change the PIN to 0000 enter
AT+PSWD=0000).
AT+ROLE=<Param> to midy the role of the module as slave or master
(Default 0, Ex: to change the role as master enter AT+ROLE=1, as slave
enter AT+ROLE=0).
To modify the baudrate, enter AT+UART=<Param1>,<Param2>,
<Param3> with Param1, 2 and 3 serial communication parameters:
baudrate, stop bit and parity bit respectively (By default,set to 9600,0,0.
Ex: to modify the baudrate to 115200 enter AT+UART=115200, 0, 0).
There are multiple AT commands available for the HC-05 Bluetooth module
on the Internet.
https://cdn.instructables.com/ORIG/FOR/4FP2/HKZAVRT6/FOR4FP2HKZA
VRT6.pdf
Slave Configuration
To set the module as a slave, you can change the name as AT+NAME=HC05-
Slave and choose the communication parameters and the PIN code that you
want. You’ll need to make sure that master and slave as the same
communication parameters.
AT returns OK
AT+NAME=HC05-Slave
AT+UART=9600,0,0
AT+ROLE=0
Enter AT+ADDR to obtain the module address (ex:
+ADDR:98d3:32:21450e)
Master Configuration
The slave module needs to be made master by changing the module's role and
setting the same communication parameters as the master module.
AT returns OK
AT+NAME=HC05-Master
AT+UART=9600,0,0
AT+ROLE=1
The slave module address must be entered in the master module to allows it to
appair: AT+BIND=98d3,32,21450e (replace dots “:” by coma “,”)
How do these AT commands work?
Hayes developed a simple command language from 1981 until 1984 to control
his smart modem, eventually combining a series of short text strings into
instructions for tasks strings which can be combined to produce commands for
operations such as dialing, hanging up, and changing the parameters of the
connection. It is from this point that the idea of enhancing the Hayes set or the
AT commands set and interacting with more devices with a prefix character is
born.
You can interface the Bluetooth modules with AT commands in order to set
their parameters like the other devices. For this reason, before we can use AT
commands on a Bluetooth module, it must first be switched to AT mode. This
tutorial will use the HC-05 and HC-06 Bluetooth modules, which are the most
common Bluetooth modules. If you use a breakout board, you can tell the
difference between these two Bluetooth from the pins
CHAPTER 5
ARDUINO PROJECTS IDEAS
1. Arduino Based Autonomous Fire Fighting Robot
Firefighters can independently detect fires with this sophisticated
firefighting robotic system. Fire fighters face an increasing risk of death as
technology leads to an automated system and self-traveling vehicles. If a fire
is not controlled, it will spread rapidly. Even an explosion is possible in the
event of a gas leak. The system delivers by overcoming this issue,
safeguarding the lives of our heroes. An Arduino Uno is used to power this
firefighting robotic system which is comprised of an ultrasonic sensor
positioned on a servo motor for obstacle detection and free route navigation.
Despite its small size, it has the capability to detect and extinguish fires. It
also has water tank and spray mechanism for extinguishing flames. Servo
motor is used to cover maximum area with water spraying nozzle. The 12V
pump uses an electric motor to pump water from the main tank to the water
nozzle. Because of its constant current consumption, this pump needs driver
circuit.
Hardware Specifications
Arduino Uno
Ultrasonic Sensor
Fire Fighter Robot Body
Fire Sensor
Buzzer
LCD Display
Resistors
Capacitors
Transistors
Cables and Connectors
Diodes
PCB and Breadboards
LED
Transformer/Adapter
Push Buttons
Switch
IC
IC Sockets
Firefighting robotic systems are designed with specific tasks in mind. The
primary aspects of fire control and suppression are analyzing and locating
fires as well as conducting search and rescue operations. Robotic systems for
controlling fire, such as automatically activating fire alarms and sprinklers,
can quickly extinguish anything in a heavily populated or hazardous area.
These systems are usually simpler and primarily rely on UV or infrared
sensors. Since they are fixed, they don't typically change over time.
Software Specifications
1. Arduino Compiler
2. Programming Language: C
Block Diagram:

2 Robot Snake based on Arduino controlled by Android


Twelve servo motors drive the snake's segments, which are joined with metal
brackets. A 7.4-volt battery pack powers the servos and controls them with an
Arduino Mega. An android app can be used to control the snake using
Bluetooth. In addition to autonomous movement, the snake is additionally
capable of passive activity. Various different types of servos and brackets can
be used to construct such a robot. There are 12 segments of the robot, each
containing a servo motor, a C-bracket, a side bracket, a set of Lego wheels,
and a wire clip. The Lego wheel axle must have two screw holes for the C-
bracket to be attached to it.
In spite of the fact that nine segments are already connected, they need to be
expanded with two tail segments in order to accommodate the Arduino and
batteries. The side brackets and C-brackets are connected to the side brackets.
A 5AA battery holder is used to power the Arduino and therefore the tail of
the snake. A separate energy supply powers the servos. That is the 7.4-volt
battery pack. The voltage pin is attached to a five-volt Arduino pin. On the
receiver, the lower pin is attached to ground.
Block Diagram:

Hardware Specifications

Arduino mega
IR Sensor
Servo Motors
Bluetooth module
Camera
Cables and Connectors
PCB and Breadboards
Push Buttons
Switch
IC

Software Specifications
1. Arduino Compiler
2. Programming Language: C
3. Smart Charger Monitoring System using Arduino
Batteries are charged or recharged by transferring energy into them via the use
of a device called a battery charger or recharger. There are a variety of
charging protocols available for batteries of different sizes and types. Smart
battery chargers are primarily switch-mode power supplies that function in
concert with battery handling and storage devices to control and monitor
charging processes.
An Arduino is used to power this smart charger. This intelligent charging
system charges three batteries with 12V power simultaneously. During full
charge, a battery is automatically disconnected from the mains. It has an
automatic power cut-off system. A smart charger is mainly an inverter for
switching on and off power supplies. It also communicates with the smart
battery packs. Moreover, the LCD display module periodically displays the
charge level for the battery.

Hardware Specifications
Arduino Uno
Relay
Relay Drivers
LCD Display
Crystal Oscillator
Resistors
Capacitors
Transistors
Cables and Connectors
Diodes
PCB and Breadboards
LED
Transformer/Adapter
Push Buttons
Switch
IC
IC Sockets

Block Diagram:

4. Automatic Sketching Machine Project


With the advent of machines, machines can now also draw perfect sketches.
Using the process proposed here, a machine can sketch pictures accurately
and fast just like a human. With an Arduino based circuit, which is attached to
motors and belt-based machinery, the designed system will be able to draw a
sketch with a pen.
In order to transmit movement commands according to the image fed into the
Arduino based circuit, two stepper motors are interfaced with it. The
sketching process is controlled then with a well-planned mechanism to
achieve this task. The motor raises the pen above the page where it is not
needed, so the pen touches the paper only where a dot has to be placed. A 2D
sketching mechanism has been created using this mechanism in conjunction
with the motion of the x and y axes.
Block Diagram:

Hardware Specifications:
Arduino UNO
Stepper Motors
Servo Motor
LED’s
Resistors
Capacitors
Diodes
Connectors & Cables
Connecting Rods
Pulley
Rubber Belts
Bed Frame
Bearings
Screws & Joints
Software Specifications:
Arduino IDE
MC Programming Language: C
5.Arduino based Sun Tracking Solar Panel
The future of mankind depends upon harnessing solar energy properly, in
place of the traditional energy sources it has used for a long time. We
branched out from the existing project to design this so solar energy can be
harnessed even more efficiently.
Block Diagram:
Software Specifications
Arduino Compiler
Programming Language: C

Hardware Specifications:
Arduino Uno R3
Solar Panel
Stepper Motor
Crystal Oscillator
Resistors
Capacitors
Transistors
Cables & Connectors
Diodes
PCB
LED’s
Transformer/Adapter
Push Button
This project is designed to be controlled by a solar panel using a controller
board based on the Arduino controller board. Solar panels harness the power
of the sun. The solar panel is attached to a motor so it can gather more solar
energy since it is incident on the sun. Electrical connections are made
between this motor and the controller board. Checking on the availability of
solar energy constantly from one horizon to another, the system makes sure
that this is happening. In the scan, the scanner determines which direction
receives the greatest amount of solar energy and therefore captures the
brightest incident sunlight. As a result, the system utilises the maximum
amount of power it can generate with the Solar Panel.

6. Internet of Things based Irrigation Monitoring & Controller System


using Arduino
A farmer is typically a person who works on a huge plot of land in order to
grow several kinds of crops. Not all farmlands can be monitored by one
person at any one time. There are times when a particular patch of land can
get so much water that it becomes water-logged, or it might get so little water
that it becomes dry. A farmer could suffer losses in either case if his crops are
damaged, or if the crops are damaged by a storm. We propose an “Internet of
Things Irrigation Monitoring and Control” project to solve this problem. One
of the features of this project is that the utility company may monitor and
regulate the supply of water from a faraway place. The Internet of Things
concept is used in this system. As such, our system uses a wireless module to
connect to the internet. A web server is connected to our desired website
using an Arduino Uno board.
Block Diagram:
In these project, two concepts are shown; a) Motor status b) Moisture level a
moisture sensor is equipped in the circuit, which keeps an eye on the soil
moisture content. Users can then control the water supply remotely by
checking the current moisture level on the website. Using the motor control
switch, the water pump can be switched from ‘ON-OFF’ to ‘OFF-ON’.
Therefore, the issue of ‘soil hydration’ can be monitored and the ‘supply of
water’ manipulated just by turning on or off the ‘motor’. Thus, there is no
need for the user to worry about his crops getting damaged because of
‘waterlogging’ or ‘drought’. A person may not be able to constantly be
present at their garden for people having small gardens. This project could be
used to keep track of “soil-moisture” and supply water even from a distance.
Hardware Specifications
Rectifier, Regulator, LCD Display
Power Supply, Wi-Fi Modem, Water Pump
Soil Moisture Sensor, Arduino Uno

Software Specifications
Arduino Compiler
MC Programming Language: C
IOT Gecko
7. Internet of Things based Smart Agriculture Monitoring System Project
Since ancient times, agriculture has been practiced in every country. Science
and art are both involved in cultivating plants. In human civilization's rise to
sedentary civilization, agriculture was paramount. Farmers have been
cultivating crops by hand for ages. Agriculture needs to adopt new
technologies and implement implements to keep up with the trending of the
world.
Block Diagram:
Agriculture is becoming smarter with the use of IoT. Technology such as IoT
sensors has the potential to provide valuable information about agricultural
fields. By automating IoT-connected smart agriculture systems, we propose a
new model. In order to monitor agriculture using IoT, wireless sensor
networks were deployed throughout the system and sent the collected data to
remote nodes using a wireless protocol.
IoT technology used in this smart agriculture consists of an Arduino, a
Temperature, and Water level, GPRS, and Moisture sensor. Monitoring the
water level, moisture, and moisture content of the soil is part of the IoT-based
agriculture monitoring system. Whenever there's a problem, it sends an alert
to the user's phone. Water level sensors sense a fall and start the pump
automatically if necessary. The fan starts when the temperature reaches that
level. The LCD display module displays all of this. This is also seen in the
Internet of Things, which provides information on Humidity, Moisture and
water level by the minute based on the date and time.
Different crops demand different temperatures; they are cultivated at different
altitudes and temperatures. If it is desired to forcefully stop the water flow
using the IOT, a button is available from which it can be forcibly stopped.

Hardware Specifications
Arduino, GSM Modem
Wi-Fi Modem
Temperature Sensor, Humidity Sensor
Water Sensor
Mini Exhaust Fan
Water Pump, Crystal Oscillator
Resistors
Capacitors, Transistors, Cables and Connectors
Diodes, PCB and Breadboards
LED
Transformer/Adapter, Push Buttons
Switch, IC, IC Sockets

8. Arduino Ultrasonic Sonar/Radar Monitor Project


These advanced Arduino sonar technologies can be utilized to screen
the patch area as well as detect suspicious objects. A car that has explosive
material in it can be controlled remotely. We are able to prevent enemies from
entering the public with this Arduino sonar radar, which in turn will save
many lives.
The Sonar Arduino system continuously scans the surrounding area and
produces a beep upon detecting a moving target that is within our range.
Moreover, the radar measures the angle and distance of the target from our
source. Our system enables us to track the exact position of the object in real
time and traces its path.
Radar: How does it work?
Radio detection and range technology is used in RADAR systems.
Microwaves are used by radar to determine the range, altitude, direction, and
speed of objects within a radius of about 100 miles of their location. By using
a radar antenna, radio wave/microwave signals are transmitted and bounced
off various objects on their path. As a result, we can estimate the proximity of
a certain object.
The operating principle is:
With the use of electromagnetic sensors , a radar can detect and locate
objects. Radiation from a radar is in the form of microwave waves or radio
waves. Reflections from objects around them can intercept the waves.
Radio waves intercepted by radar are reflected in many directions after they
reach their target. The radar can direct these waves back to the receiver after
receiving and amplifying them. Once again receiving these waves at their
origin indicates that an object is in the propagation direction.
In addition to air traffic control and air defense, radar astronomy, antimissile
systems, and outer space surveillance are some applications of modern radar
systems.
Block Diagram:

Hardware Specifications
Arduino Uno
Ultrasonic Sensor
Servo Motor
LCD Display
Resistors
Capacitors
Transistors
Cables and Connectors
Diodes
PCB and Breadboards
LED
Transformer/Adapter
Push Buttons, Switch
IC, IC Sockets
Software Specifications
1. Arduino Compiler
2. Programming Language: C
9. Smart Dustbin with IOT Notifications
Increasing populations result in an increase in trash in urban areas. With IoT
and sensor-based circuitry, we present here an intelligent dustbin that can
assist in solving this problem. In the normal dustbin, you must open it with
your foot and throw garbage. Also, a person must remember to empty their
trash cans when they are at capacity, so they do not overflow. In this paper we
develop a smart dustbin which can do all of these tasks without any human
involvement. Essentially, our system pairs a clap sensor with a foot switch. In
response to the clap or foot tap, the door opens and closes automatically by
itself.
Block Diagram
Upon receiving the signal, the dustbin opens its hatch and closes it.
Additionally, the dustbin has an ultrasonic level sensor that continuously looks
for level changes and triggers an automatic alarm if garbage is expected to fill
the bin. A smart circuitry inside the dustbin sends data to the garbage
collector over the internet, so he can empty it, if necessary. Web development
of the IoT system is carried out using IoT Gecko. In offices, homes and public
places this bin is of great use for garbage disposal. Therefore, garbage can be
automatically cleaned with the help of an automated smart dustbin.
Hardware Specifications
Arduino Uno
Ultrasonic Sensor
Mic Sensor
Wi-Fi Module
Resistors
Capacitors
Transistors
Cables and Connectors
Diodes
PCB and Breadboards
LED
Transformer/Adapter
Push Buttons
Switch
IC
IC Sockets
Bin Frame
Mounts & Joints
Supporting Frame
Software Specifications
Arduino Compiler
Programming Language: C
IoT Gecko
10. Open-Source COVID-19 Pulmonary Ventilator
The non-invasive, open-source ventilator is easy to build and is low-cost if
there are no ventilators available and no patient is sedated or intubated while
the patient needs to be ventilated. This project was inspired by a challenge I
accepted from my former teacher and friend Serafim Pires. He presented a
Spanish project to me and asked me to create a project to help fight the
worldwide economic crisis. This functional prototype was built on the basis
of two existing technologies, after conducting several researches and tests on
the topic of non-invasive ventilation. All tests were successful and the
functional test lasted in excess of 20 days without any interruption.
Components Required
Arduino UNO
Arduino 4 Relay Shield
Digital Servo MG995 , LM2596S Module
10k linear Multi-turn Potentiometer
Digilent 60W PCle 12V 5A Power Supply
5mm LED Red , 5mm LED Green
Alphanumeric LCD 20*4
Switch button 220V
Snorke Full Face , Solenoid Valve, 2 ways

Software Specifications

Arduino Compiler
MC Programming Language: C
Circuit Diagram of COVID-19 Pulmonary Ventilator

Through the use of nasal and face masks, non-invasive ventilation is made
possible by delivering controlled amounts of compressed air into the lungs.
This helps the body fight infection and recover when the lungs are failing from
disease. During the height of the coronavirus outbreak, and based on research
conducted in Italy, I turned a Decathlon snorkel mask into an emergency
ventilator for patients suffering from COVID-19, in order to reduce the lack of
ventilators. Because of their low cost and ease of adaptation, these masks are
used throughout the world.

WARNING:
This prototype does not have official validation, nor will I accept any
responsibility with it.
Furthermore, this equipment is intended to save lives in an extreme
peak situation and will be used as a last resort by trained medical
personnel.
In Portugal, the Portuguese authorities may approve the duplication of
the non-profit project in bulk.
11. Advanced Automatic Self-Car Parking using Arduino
Both developed and developing countries facing a major car parking
issue in urban areas. Several cities lack car parking areas as a result of the
rapid rise of car ownership. A significant part of this imbalance results from
ineffective land use planning and a miscalculation of space requirements at
the start of the planning process. There are several examples of problems that
arise from parking throughout the day, such as lack of parking space, high
parking rates, and the congestion of traffic caused by visitors in search of a
parking spot. Parallel parking is generally the worst nightmare a driver has
because not only is it difficult if you do it well, but it increases the risk of
other drivers hitting your parked vehicle. We developed an automated parking
system to solve the above parking problems, thus enabling cars to park
themselves. A self-parking car project is a self-parking car which utilizes an
Arduino board, obstacle sensor, ultrasonic range finder to identify the parking
distance. This robot uses a small LCD module to display various program
information, a DC motor and servo motor for steering, and several algorithms
for path finding.
Hardware Specifications
Robotic Chassis
Arduino
Ultrasonic
Servo Motor
Resistors, Capacitors, Transistors
Cables and Connectors
Diodes, PCB and Breadboards
LED
Transformer/Adapter
Push Buttons, Switch
IC
IC Sockets

Block Diagram
Software Specifications
Programming Language: C
12. Rotating Solar Panel Using Arduino
The energy demand in the commercial and residential markets is growing
rapidly over the last few years. It leaves no other choice but to rely on
renewable resources to generate usable energy as non-renewable resources
are rapidly dwindling. Solar panels are another way to harness solar energy
as it is the easiest and most abundant resource. Using this method, solar
energy can be harnessed more efficiently.
It uses a Solar Panel attached to a rotating platform, which is powered by a
motor, to charge a 12VDC Battery. An Atmega328 microcontroller attached to
an Arduino Uno board, mounted on the PCB, is controlling this motor. In order
to know the current position of the sun, the Rotating Solar Panel system scans
from one horizon to another. This allows the greatest solar energy to be
harnessed from that position. It is chosen to charge the Battery at the position
that has the highest energy capacity. By aligning the Solar panel against the
Sun, we can harness the most benefit from it. Thus, harnessing solar energy
under this project is more efficient and thus smarter.
Block Diagram:

Hardware Specifications
Arduino
Servo Motor
Solar Panel
Solar Panel Mount
Resistors
Capacitors
Diodes
Screws

Software Specifications
Arduino Compiler
Programming Language: C
13. Touch Free Hand sanitizer dispenser using LDR
Touch-free hand sanitizer dispenser that automatically dispenses sanitizer
utilizing LDR sensors and MOSFETs to switch the motor we designed this to
be in accordance with COVID 19 coronavirus .

Coronavirus (COVID-19) is spreading across the world. Nearly every


country is experiencing the devastating effects of the Coronavirus. A
Pandemic disease has been declared by WHO and many cities are in
lockdown situations. Many people's lifestyles have been changed drastically.
Globally, the WHO is advising disease control officials to maintain Healthy
Hand washing and Sanitation Habits, but our problem mainly involves our
physical contact when we do this. The virus can be spread by touching
infected bottles of alcohol or sanitizers with infected hands. We will make an
automated hand sanitizer dispenser by using infrared sensors to detect a hand,
and an automatic pump will pour the liquid on the hand.
Many Arduinos automated liquid dispensers are floating around the web.
Nevertheless, my aim is to keep it straightforward and inexpensive, so anyone
can produce it. A simple transistor or MOSFET with an IR proximity sensor
would probably be the easiest solution for this purpose, and it would
drastically reduce the costs as well. Because no microcontroller is present,
spills are unlikely to be controlled, but the use of a smaller nozzle may reduce
the flow of liquid.
Components Required
Arduino UNO & Genuine UNO
Fairchild semiconductor
Power MOSFET N-Channel
LDR, 5 Mohm
Fairchild semiconductor 1n4004.
1N4007 – High Voltage, High Current Rated Diode
Fairchild semiconductor 1n4004.
1N4007 - High Voltage, High Current Rated Diode
09590 01, LED (generic)
Resistor 220 ohm
Keystone 233 image 75px
9V Battery Clip
Automatic Dispenser
A basic working principle of the automatic sanitizer dispenser is that when
the distance sensor detects an obstruction within its line-of-sight, it will
trigger the servo to turn on the sanitizer tap.
When the person's hand gets in the way of the sensor and obstructs the line of
sight, the Arduino board detects the low distance and instructs the servo motor
to activate the sanitizer.
Circuit Diagram:

Here is the Circuit Diagram of a sanitizer or alcohol dispenser based on IR


sensor. No microcontroller is required.
14. IoT Based Home Automation controlled by smartphone
Human life is increasingly driven by the use of automation, whether it's at
home or at work. Automation in the manufacturing industry is a concept that is
frequently used to automate large machines and/or robots to facilitate
increased production, energy, and time efficiency.
In contrast, home automation affects the environment of the homeowners. The
smartphone and the internet have allowed us to do this. There are two main
ways of home automation. One type is controlled by just a smartphone, while
the other type involves sensors and actuators to control lighting, temperature,
door locks, electronic gadgets, and electrical appliances.
Essential Components
Arduino UNO
12 V Relay X 4
HC – 05 Bluetooth Module
Prototyping board (Bread board)
Connecting wires
12 V Power supply
Smartphone or tablet (Bluetooth enabled)

Modern homes require sophisticated control in the electronic appliances they


have in their homes. As a result of the integration of home appliances with
smart phone and tablet connectivity, the home automation field has been
transformed, enabling a greater level of affordability and simplicity. In
addition to the features, they have already, smart phones can be made to
communicate with any other device in an ad hoc network through connectivity
options like Bluetooth. As mobile phones have become more prevalent,
development of mobile applications has also increased. A mobile phone
commonly found in a traditional household can be connected to the electronic
equipment of a smart home in a temporary network using the opportunity of
automating tasks for a smart home.
The Android mobile application platform is provided by Google Inc., which
is used to develop applications for Android phones and tablets. Android-
based home automation system will benefit the masses as it targets a large
market who uses it for their mobile devices. Android maintained its
leadership position in the Worldwide Quarterly Mobile Phone Tracker,
published by International Data Corporation (IDC). Using Bluetooth for home
appliances and mobile phones in an ad hoc network environment, such as in
your home, is an excellent solution for short-range wireless communication. A
wireless technology works over 2.4 GHz frequency range up to a distance of
100 m with 1 Megabit per second, making it a secure and efficient method for
controlling home automation.
The beauty of the Home Automation system is being able to adjust the settings
from your smart phone or other remote-control device. Smart technology can
lower costs and conserve energy in your home. For example, smart lights,
TVs, and other appliances are part of the Home Automation segment.
Wearables (Smart Watches, fitness brands, smart headphones, smart clothing)
will also grow in the future. This entire system is driven by the Internet of
Things. As of today, nearly 22.5% of Indian consumers have heard of IoT,
with the highest awareness observed in the 36-55 age group, which indicates
that there is an enormous opportunity for these technologies to be adopted
more widely. With a few key updates to Automation technology, the future of
the home automation market will be bright. In the near future, wireless
automation solutions may also be available, as well as a lowering of prices as
the market accepts the use of home automation in greater numbers. By 2020,
the connected devices segment is expected to grow significantly due to
increased internet penetration and use of data. Automating the home in India
presents a large opportunity both for Indian and foreign automation
companies. As home automation develops along with M2M (machine-to-
machine) communication, billions of new connected objects will emerge over
the next five years and beyond.
15. Covid-19 Patient Monitoring Device based on LoRa using The Things
UNO
Lora network based covid-19 patient monitoring device.

Using sensors and connected networks, we have developed a patient


monitoring system that can autonomously monitor patients’ health conditions.
The Covid-19 system was specially manufactured for patients with this
condition. The biological behaviour of a patient can be gathered by several
sensors. Information about biological processes then goes into the IoT cloud.
By processing sensor data, the system is more intelligent, and can tell when a
patient is in critical condition. Nurses and doctors receive instant alerts and
hospital personnel receive push notifications. Nurses and doctors’ benefit
from this system because they can observe the patients remotely without
having to visit them personally. Relatives of patients can also gain access to
the system with limited access.
This monitoring system is controlled using the Things UNO, a Lora
development board. This board collects information from various health
sensors (described in the Hardware Components section) that provide
information about patient health parameters. Data transmission from the
Things UNO to the Lora Gateway (The Things Gateway) is also handled by
the Things UNO. The Lora gateway provides a connection to the Amazon Web
Services IoT cloud platform. This cloud is used for managing this system.

The data has been visualized using a Mobile application. For displaying real-
time sensors data, such as the present health condition of a patient, various
charts and gauges have been employed. Doctors and nurses can use this
application remotely to monitor patients without visiting an ICU unit. A push
notification is sent to appropriate doctors or nurses regarding the emergency
situation of the patient due to the nature of intelligence, by processing the
sensor data, Equation -I identifies the patient's emergency condition. During a
24-hour period, the hospital in charge personnel (ICU in charge person)
continuously monitored multiple patients online via our cloud-based desktop
application (shown in Figure), which makes the ICU process more efficient,
Throughout the application's lifetime, all of the applications tapped into the
Internet of Things and visualized the data in real-time, using visualizations
such as gauges, Sparklines, and Text.
16. Open-Source Pulse Oximeter for COVID-19

This is an easy-to-make, USB-powered pulse oximeter that can be built for


around $20 and features an OLED display.
The SARS-CoV-2 virus is the virus responsible for causing COVID-19, a
disease which mostly attacks the respiratory system. Fever, chills, and muscle
aches and pains are some of the milder symptoms, but a severe case can lead
to pneumonia. A person suffering from pneumonia or even slight shortness of
breath might not recognize when to seek medical attention, especially when
they begin to feel even worse. Hence, I am developing this open-source pulse
oximeter so that the people can be better informed about their current
condition and which can assist them in getting the help they need.
Disclaimer
Using this device for accurate medical diagnosis is not recommended!
17. Touch less doorbells can operate without touching the switch.

One of the most effective ways to escape from COVID-19 is through social
isolation. Staying at home is strongly recommended in the beginning days.
However, we still have to make some emergency visits to certain homes. We
first searched the doorbell button of a house when we arrived. Then press the
doorbell button. However, in this specific situation, this doorbell button can
cause the virus to spread. A virus is held on the button when someone who is
not infected presses the button, and when a second person touches the button,
the virus is spread. A touchless doorbell will help to eliminate this danger.
Touchless doorbells are available to convert existing doorbells.
Working
Infrared LED transmitters transmit light within the range of the infrared
spectrum. Wave length of IR waves is longer than wave length of visible light.
This transmitted IR light will be picked up by the photodiode receiver. The
photodiode will only conduct when it is illuminated. The semiconductor is
reverse biased as well.
It can be shown that the current flow is directly proportional to the amount of
light it receives. In this photo, we see the LM358 Operational amplifier in
voltage comparator mode. Comparison is made between the voltage set by the
variable resistor and the voltage set by the photodiode series resistor

(PSR voltage). A ground connection is maintained between the


"OUTPUT" pin and the OP-AMP output.
The PSR Voltage has dropped below the Threshold Voltage - the
output is HIGH
Voltage drops on PSR < Threshold Voltage - Output is LOW
By calibrating the variable resistor, the distance at which objects
should be detected can be determined.
Key point
In case an object is presented in front of the sensor, the sensor output will be
HIGH, but if not, the sensor output will be LOW
Essential Components
Arduino Nano R3, Relay, IR Sensor, Buzzer
A signal will be sent to the Arduino board when we show our hand to the IR
Sensor. And Arduino drives the relay. The relay is connected to the doorbell.
The bell will ring the moment the relay is activated.
18. Social Distancing Device (Safety Card)

During this pandemic, we trust everyone is following social distancing and


keeping safe, which is why we made an ultrasonic sensor device at my home
to do social distancing. With this device, a buzzer sounds and vibration occurs
when the distance between two people is less than one meter, signaling that
the distance needs to be maintained.
Components Required
Arduino UNO, Ultrasonic Sensors, Buzzer, LED
The device automatically turns off if the space is greater than 1 meter.
Circuits Diagram
I
think this is a very interesting and useful project that you can easily build at
home. Wearable’s can be manufactured by using an Arduino Nano or you can
shrink their size by using an Arduino Micro. Put together the materials like
Arduino Uno Arduino Nano, ultrasonic sensor, buzzer, vibrator motor, 9v
battery, switch, card or cardboard box, Velcro strips, take the card and glue
the face of the box with the electronics, proceed to upload the code, Once the
code has been uploaded, place the Arduino inside the box, along with the
switch, nine-volt battery, and circuit symbols, and do circuit connections.
Attach the front portion of the box and then check that everything functions
well, now decorate the box and stick it with Velcro.
19. Automatic Faucet (Touchless) for COVID-19 Using Arduino
Wash your hands comfortably and avoid getting coronavirus disease. Don't
touch the surface of the faucet after you wash them.
A disease caused by the severe acute respiratory syndrome coronavirus 2 is
known as coronavirus disease (COVID-19), also known as the coronavirus
severe acute respiratory syndrome (SARS-Cov-2). More than a million
people worldwide have been affected by COVID-19 and hundreds of
thousands of people have lost their lives as a result. People are affected by
this disease in different ways. Many people develop mild to moderate
illnesses that require no hospitalization or special treatment, while others
develop severe illnesses that ultimately lead to death. A person infected with
this virus can incubate for an average of 5-6 days, but it can also incubate for
2 weeks. It could be contagious during this period, even though the person
may not be experiencing any symptoms. If the person doesn't take any
precautions, he will be a virus carrier and will spread the illness easily.
Components Required
Arduino Nano R3
Solderless Breadboard Half Size
Jumper wires (generic)
Ultrasonic Sensor - HC-SR04 (Generic)
Submersible water pump - 5V
Relay Module (Generic)
Coronavirus has been spreading rapidly around the world and will continue to
spread. The second wave of the coronavirus is still affecting some countries
while others are still in lockdown and still aren't seeing any recover y .
Program

#define trig 5
#define echo 4
const int Relay = 6;
long duration;
int distance;

void setup() {
pinMode(trig, OUTPUT); // Set the trigger pin as OUTPUT
pinMode(echo, INPUT); // Set the echo pin as INPUT

pinMode(Relay, OUTPUT); // Configure the pin of the relay module as


OUTPUT
Serial.begin(9600); // Set baud rate as 9600
}
void loop() {
digitalWrite(trig, LOW);
delayMicroseconds(5);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
duration = pulseIn(echo, HIGH); // Calculate time taken (in microseconds)
for the pulse emitted by the trigger pin to reach the echo pin.

distance = (duration/2) * (331.3/10000); // Calculate the distance from the


sensor to the obstacle in cm, using the speed of sound in air(m/s) and the time
taken (stored in duration variable)

Serial.println(distance);
if(distance>1 && distance<10){
digitalWrite(Relay, HIGH); //Turns on the submersible water pump or
solenoid water valve
}
Else
{
digitalWrite(Relay, LOW); //Turns off the submersible water pump or
solenoid water valve
}
delay(2000); // Set a delay period of 2 seconds to prevent the clicking of the
relay module
}
20. Obstacle Avoiding Robot using Arduino
A simple Robot Obstacle avoidance project is designed here. The field of
robotics is fast growing and has a lot to offer. Technology advances are
increasing the applications of robotics since it is a branch of engineering.
Mobile Robots are becoming more and more complex, and the number of
mobile robots and their applications are increasing rapidly.
The navigation techniques used for mobile robots include path planning, self-
localization and map interpretation. Robot-type vehicles known as Obstacle
Avoiding Robots are designed to avoid collisions with unexpected obstacles.
We have designed an obstacle avoidance robot in this project. Ultrasonic
range finders are the key to avoid collisions with this Arduino-based robot.
Hardware Required
Arduino Uno
Ultrasonic Range Finder Sensor – HC – SR04
Motor Driver IC – L293D
Servo Motor (Tower Pro SG90)
Geared Motors x 2
Robot Chassis
Power Supply
Battery Connector
Battery Holder
Ultrasonic Sensor
You need to know how the ultrasonic sensor works before tackling the
project, read chapter 1 for more information on ultrasonic sensors. Ultrasonic
Ranger - uses ultrasonic waves to measure distance between sensors and
objects based on the time between generating the ultrasonic wave and
receiving its echoes. There are four pins on the HC-SR04 Ultrasonic sensor:
Vcc+, Trigger, Echo, and Ground.
21. Arduino Bluetooth with MATLAB for Wireless Communication
This protocol is the most popular solution for wireless communication in
embedded systems due to its simplicity and ability to support short range
communication. Besides being used to transfer data between two devices but
also to control them wirelessly, Bluetooth is also used for controlling certain
devices. Bluetooth is built into almost every electronic gadget nowadays, so
securing Bluetooth control in your embedded app is a wise choice.
Using Bluetooth in MATLAB and wireless communication, we will learn how
to accomplish this in this tutorial. On one side, we will use Bluetooth in
MATLAB, and on the other, we will use HC-05 with Arduino. MATLAB and
Arduino can communicate via Bluetooth in two ways, one via the command
window and the other via MATLAB GUI. Both of these methods use the same
Arduino code.
Components Required
MATLAB installed Laptop (Preference: R2016a or above versions)
Arduino UNO, Bluetooth Module (HC-05)
LED (any color)
Resistor (330 ohm), Jumper Wires
Circuit Diagram
The following schematics are needed to communicate between MATLAB and
Arduino using Bluetooth.

The Arduino UNO needs to be uploaded with the given code and then
MATLAB Command Window should be used to start programming.
#include <SoftwareSerial.h>
int TxD;
int RxD;
int data;
SoftwareSerial bluetooth(TxD, RxD);
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
}
void loop()
{
if(bluetooth.available() > 0)
{
data = bluetooth.read();
Serial.print(data);
Serial.print("\n");
if(data == '1')
{
digitalWrite(11, HIGH);
}
else if(data == '0')
{
digitalWrite(11, LOW);
}}}

Then, copy and paste the below MATLAB code in the Command window for
Bluetooth communication between MATLAB and Arduino.

Arduino can be programmed in MATLAB. For MATLAB to run on Arduino


target hardware, you need to install a support package from add-ons. The
Bluetooth modules HC-05 or HC-06 can be used.
For more information about Bluetooth communication through MATLAB,
please refer to the below link
https://www.mathworks.com/help/instrument/reading-and-writing-data-over-
the-bluetooth-interface.html
22. Coronavirus Sterilizer Box | Food Mask Sterilizer
The Covid technology revolutionized 2020 for all of humanity. The
way it spread rapidly forced us to wear face masks and gloves to protect our
skin from everything we touched. Certainly, we can put on a mask when we
are outside but what do we do if we bring something home from the store or
trade with someone else? The fact that patients and employees exchange files
and paperwork with doctors or with each other, cannot be sanitized by
applying sanitizers to these outside items.
Circuit Diagram
Using an Arduino-powered system powered by a smart electronics chip, we
solve this huge problem. To solve the problem, we designed an ultraviolet-
sanitizing box that has a 60-degree angle. 8 uv tubes are employed by the
system in order to achieve this task. All viruses have been killed by UV C in a
matter of seconds:

Components
Arduino Uno
LCD Display, Buzzer
Lid Sensor
UV-C Tubes, Buttons
Metal Mesh, LED’s
IC’s , Resistors
Capacitors
Diodes, Transistors
Transformer
Base frame, Supporting Frame
Mounts and Joints
Screws and Bolts

The Arduino COVID Disinfection box has the following Key Aspects
A 360-degree approach to disinfection
All Coronaviruses can be deactivated.
Shutdown and alerts based on timers
Sterilizes masks, packaged foods, electronics etc.
Specifying the duration of the sterilization
Shut off automatically
Easy To Use
We use no water and no chemicals | Environmentally friendly
Sterilization starts when the start button on the Arduino controller is pressed
and the controller takes user inputs for time setting. This device shuts off
automatically after it reaches the sterilization temperature. Another shutoff
system also prevents lipids from being opened by users while sterilization is
taking place.

Advantages
No Chemicals or Water Sterilization
Sterilization at 360 degrees
Demonstrated to deactivate Bacteria and Viruses
Sterilization time that can be adjusted
Untimely opening will result in automatic safety shut off.
Disadvantages
Since it is not large enough to sterilize large objects, it is not suitable.
It does not have a battery and is not suitable for car use.
If you are interested in learning more about a specific UVC lamp, you
can:
Make sure to find out what the product's health and safety risks are,
and whether or not instructions or training are available.
Ask whether ozone is generated by the product.
Find out what materials are compatible with UVC disinfection.
Find out if the lamp contains mercury. You may need to know how to
clean up and/or dispose of the lamp if it is damaged.

23. Bluetooth Controlled Servo Motor using Arduino


Robots are controlled precisely by using a Servo motor. Using an Arduino
UNO and an Android device via Bluetooth, we will show you how to control
a Servo motor via Bluetooth connection. Previously we controlled servo via
Arduino, this time we will use Bluetooth Module HC-6 to control Servo
wirelessly.
Material Required
Arduino UNO,
HC-05 or HC-06 Bluetooth module
Servo Motor,
Roboremo App from PlayStore
Breadboard,
Connecting wire
HC-06 Bluetooth Module
How it works
Sending data packets to the Bluetooth module is done by the android app.
These data packets are then transmitted via serial communication to the
Arduino Uno. A servo motor is controlled by Arduino Uno based on the value
of the data packet. The flowchart below illustrates how this works.
Bluetooth can operate in the following two modes:
1. Command Mode
2. Operating Mode
Command Mode will allow us to change the Bluetooth properties, like the
name of the Bluetooth signal as well as the password, baud rate and range of
features. This is the mode in which the PIC Microcontroller can transfer and
receive data with a Bluetooth module.

Thus, the Operating Mode will be our only discussion in this tutorial. We will
use the default settings for the Command mode. All Bluetooth modules will
use a default baud rate of 9600. The Device Name is HC-05 and the password
is 0000 or 1234.
Conclusion
This project demonstrates how to control your servo motor in a
simple manner.
The Arduino and Bluetooth Module in this project can control any
servo motor.
A beginner can use this project as a stepping stone towards
implementing several more complex Robotic Projects.
24. Automatic Pet Feeder using Arduino
A Pet Feeder based on Arduino can automatically deliver food to your pet on
schedule. Your pet should be fed on time and date set by the DS3231 Real
Time Clock module. The device drops or fills the food bowl depending on
your pet’s eating schedule, so set the time accordingly.
Circuit Diagram

DS3231 RTC Module and Arduino UNO are used in this circuit to display the
time on a 16*2 LCD. Also, a servo motor is used to provide the food by
rotating the containers and a 4*4 matrix keypad should be used to set the
feeding time. Depending on the quantity you want to serve your pet, you can
set the rotation angle and duration of dish opening. Aside from the size of your
pet, the amount of food you ought to give him also depends on whether he is a
cat, a dog, or a bird.
Material Required
Arduino UNO, 4*4 Matrix Keypad
16*2 LCD, Push Button
Servo Motor
Resistor, Connecting Wires
Breadboard
We have used RTC (Real Time Clock) Module for time and date acquisition
in this Arduino based Cat Feeder. With the help of the 16x2 LCD, we made
the Stepper control Pet’s eating time by using a four-by-four matrix keypad.
When the user sets the time, the Servo motor rotates the container and drops
the food on the determined date and time. In the video on the end, you can see
complete working of the LCD. Date and Time can be displayed on the LCD.
DS3231 RTC Module

RTC (Real Time Clock) module DS3231 works with the DS3231
microcontroller. Many of the Electronics projects rely on it to keep track of
the date and time. When the main power is removed from the module or if the
MCU has undergone a hard reset, the module will maintain the date and time
using the coin cell battery power supply.
This module will always keep track of the date and time once the date and
time have been set. In our circuit, we are using the DS3231 to make the pet’s
owner set the feeding schedule, like an alarm, to the pet’s daily food
requirements. The clock opens the container gate when the timer reaches the
set time and drops the food into the Pet’s bowl.
Note: You can also use the RTC IC DS1307 to read the time if you use this
module for the first time.

3D-Printed Pet Feeder Model

The Arduino Pet Feeder container prototype is printed with a 3D printer.


25. Arduino Based AC Home Appliances controlling with thermistor and
relay
If you were sitting in a cold room and you wanted your heater to be
automatically turned on, then that might be possible. Usually, when a room
temperature increases, appliances are turned on for some time and then off,
making the project useful for controlling home appliances according to the
temperature. With Arduino, we control our home air conditioning systems
based on the temperature. A Thermistor was used to measure temperature in
this case. The Thermistor was interfaced with Arduino and the temperature
was displayed on LCD.
We will use the Arduino temperature-controlled system in this tutorial to be
able to control an AC appliance using a Relay. Displayed on the 16*2 LCD
display with connection to the circuit are the current temperature and
appliance status.
A variety of components are used in this Home Automation System, including
an Arduino board, LCD display, relay and thermistor. Basically, the whole
system works by using a relay and a thermistor; as the temperature rises, the
relay will turn on and as the temperature drops below the threshold, the relay
will turn off.
Relays will also enable and disable the appliance attached to them. CFL
bulbs are used as AC appliances in this system.
Circuit Diagram
The Temperature based Home Automation System contains components such
as an Arduino board, LCD display, thermistor, Relay, and Relay. The relay
and the thermistor are key elements in this system. As the temperature
increases so does the relay. If it drops below the preset temperature the relay
is turned off.
The Relay will also control the home appliance connected with it. For this
example, an AC appliance is connected as a CFL bulb. The Arduino board is
programmed to trigger the entire triggering procedure and set the temperature
value. On the LCD screen, we can see the temperature at every half second, as
well as the status of the appliances.
The Arduino Servo Motor library takes care of all electronic properties of the
servo, so you just need to enter this angle and there is a function
servo1.write(angle); which will rotate the servo to the desired angle.
Material Required
Arduino UNO
Relay (5v)
16*2 LCD display
Light Bulb (CFL)
NTC thermistor 10k
Connecting wires
Resistors (1k and 10k ohms)
Potentiometer (10k)
Thermistor
Thermistor is the key component in this circuit, which is responsible for
detecting temperature rise. Temperature-sensitive resistors measure resistance
by changing according to temperature, called thermocouples. We are being
tested with a NTC thermistor.
Both types of thermistors have negative temperature coefficients and positive
temperature coefficients. The resistance of an NTC thermistor increases with
rising temperature, while the resistance of a PTC thermistor increases with
rising temperature.
26. IoT based Air Pollution Monitoring System using Arduino
This project involves the development of an Internet of Things (IoT) based
service that monitors air pollution over the Internet through a web server, and
it will sound a warning if sufficient amounts of hazardous gasses like carbon
dioxide, smoke, alcohol, benzene and NH3 enter the air at a certain level. On
the LCD and on the webpage, we will be able to read the air quality in PPM,
so we can easily monitor it. This time the air quality sensor was the MQ135
sensor instead of the MQ6 sensor, which we used previously for making LPG
detectors. The MQ135 sensor can detect most harmful gases without affecting
their amount.
You can monitor pollution levels in this IOT project using your computer or
mobile device no matter where you are. In addition to installing this system
anywhere, we can also set up some device that will turn on the exhaust fan or
send SMS/email notifications to the user when pollution reaches some level.
Required Components:
MQ135 Gas sensor
Arduino Uno
Wi-Fi module ESP8266
16X2 LCD
Breadboard
10K potentiometer
1K ohm resistors
220-ohm resistor
Buzzer
Circuit Diagram and Explanation:
In order to use ESP8266, we need to first connect it to the Arduino. You can't
use Arduino to power an ESP8266 as it runs on 3.3V, but if you give it 5V,
then it won't function properly and might even be damaged. 3.3V should be
connected to VCC and CH_PD on Arduino. When connected directly to the
Arduino, the RX pin of the ESP8266 works with 3.3V voltage and thus cannot
communicate with the Arduino. Thus, we will need to create a voltage divider
so that the 5V can be converted into 3.3V. You can do this by increasing the
resistance of three resistors as we did in the circuit. By connecting the
ESP8266's TX pin to Arduino pin 10, and its RX pin to Arduino pin 9, you
can make the ESP8266 transmit data.
Your projects can connect to the internet and Wi-Fi using an ESP8266 Wi-Fi
module. You can create very powerful projects with this inexpensive device.
ESP8266 is a leading IOT device, capable of communicating with any
microcontroller. Discover more about using ESP8266 with Arduino here.
Our next step will be to connect the MQ135 sensor to the Arduino. The
sensor's VCC and ground pins should be connected to the Arduino's 5V and
ground, while the sensor's Analog pin should be connected to the Arduino's
A0. In addition, we'd like to connect the LCD to the Arduino through pin 8,
which is responsible for beeping when the condition occurs.
Working Explanation:
A gas sensor can detect NH3, NOx, alcohol, benzene, smoke, CO2, and a few
other gases, so the MQ135 sensor is ideal for our Air Quality Monitoring
Project. With Arduino we can detect the pollutants, and we will get their
concentration in parts per million. Gas sensors such as MQ135 provide output
based on voltage levels that must be converted into PPM. Therefore, I have
used a library for MQ135 to convert the output in PPM, and you can find the
details below in the "Code Explanation" section.
Despite being within a safe limit of air quality (350 PPM), the sensor gave us
a value of 90 when no gas was close by. It causes headaches, sleepiness,
stagnant, stale air, and increased heart rate when it exceeds 1000 PPM and
changes can be seen in other conditions when it exceeds 2000 PPM.
The LCD and webpage will display "Fresh Air" when the value is less than
1000 PPM. A buzzer will start beeping every time the value reaches 1000
PPM, displaying "Poor Air, Open Windows" on the LCD and webpage. In the
event that it reaches 2000, the buzzer will continue to beep and the LCD and
webpage will indicate "Stay away from fresh air".
27. IOT Based Dumpster Monitoring using Arduino & ESP8266
We will build an Internet of Things (IOT) based garbage can
monitoring system in this DIY that will let us know when the trash can is full
or empty by monitoring the webserver, enabling you to control the trash can
from anywhere. Aside from being highly useful, it can also be placed on trash
cans in public areas and private homes.
Within this Internet of Things project, ultrasonic sensors are used to detect
trash can content. The Ultrasonic Sensor is mounted on top of the trash can
and measures how far the trash is from the sensor. Based on the size of the
trash can, a threshold value can be set for the distance between the trash and
the sensor.
When the distance is less than this threshold value, the trash can will be full of
garbage, and a message "Basket Full" will be printed on the webpage. If the
distance is greater than this threshold value, however, the container will be
empty. The threshold value has been set to 5 cm in our program code. A Wi-Fi
module called ESP8266 is used to communicate between the Arduino and the
webserver. On a local web server, we demonstrated our Garbage Monitoring
System.

Components Required:
Arduino Uno (you can use any other)
ESP8266 Wi-Fi module
HC-SR04 Ultrasonic sensor
1K Resistors
Breadboard
Connecting wires
Circuit Diagram and Explanation:
In order to use ESP8266, we need to first connect it to the Arduino. You
cannot power the ESP8266 with 5V from an Arduino or it won't function
properly and may get damaged. It runs on 3.3V. 3.3V should be connected to
VCC and CH_PD on Arduino. When connected directly to the Arduino, the
RX pin of the ESP8266 works with 3.3V voltage and thus cannot
communicate with the Arduino. A voltage divider will be needed, so we will
be using three 1-k resistors in series. In the circuit diagram below, you will
see the RX is connected to pin 11 of the Arduino, along with the TX, as well
as the TX of the Arduino is connected to pin 10.

HC-SR04 ultrasonic sensor now needs to be connected to the Arduino.


Ultrasonic sensors connect to Arduino boards in a very simple manner. An
ultrasonic sensor's VCC and ground should be connected to the Arduino's 5V
and ground. You should connect pin 8 and pin 9 of the Arduino to the TRIG
and ECHO pins of the ultrasonic sensor, respectively.
DEMO OUTPUT
In the Serial Monitor, you can view the IP address of the code after it has been
uploaded.

The output is shown below if you type in this IP address into your browser.
For a second look at whether the trash can is empty, you must refresh the page
again.
28. Weight measurement using Arduino, the HX711 Module, and a load
cell
The Load Cell and Weight Sensor HX711 will be connected to the Arduino to
measure weight. The weight of an item is displayed by an automated weight
machine in many shops. Users place the item on the platform and the machine
displays the weight. Therefore, there is a weighing machine that has been built
with Arduino and Load cells, which is capable of weighing up to 40kg.
Further increase of the limit is possible by using more capable load cells.
Required Components:
Arduino Uno
Load cell (40kg)
HX711 Load cell Amplifier Module
16x2 LCD
Connecting wires
USB cable
Breadboard
Nut bolts, Frame and base
Load Cell and HX711 Weight Sensor Module:
Load cells are electronic transducers that create an electrical signal from
force or pressure. Indirectly related to the force applied is the magnitude of
the electrical output. During application of pressure, strain gauges in load
cells deform. When the strain gauge is deformed, the effective resistance
changes, so electrical signals are generated. Four strain gauges are typically
used as part of a Wheatstone bridge to form a load cell. These load cells can
weigh up to 40kg, and come in different ranges like 5kg, 10kg, 100kg and even
more. Here, we are using a Load cell that can weigh up to 40kg.

Because the load cell has an output voltage in the range of a few millivolts,
these signals require further amplification, hence the HX711 Weighing Sensor
is required. An HX711 chip is used in the HX711 Weighing Sensor Module,
which is an A/D converter with 24 high-precision channels. Two analog input
channels can be programmed in the HX711 for gains up to 128 by
programming them. So the HX711 module outputs the low electrical signal
from the load cells which is then amplified and digitally converted before
being fed to Arduino to calculate weight.
Four wires are used to connect the load cell to the HX711 Amplifier. Red,
black, white and green/blue wires make up these wires. Wire colors may vary
slightly from one module to another.
RED Wire is connected to E+
BLACK Wire is connected to E-
WHITE Wire is connected to A-
GREEN Wire is connected to A+

Fixing Load Cell with Platform and Base:


Weights may be applied directly to the load cell without the Platform step.
Although the clamp can simply be attached to the plate without a base, a
platform should be attached for putting large objects on it, which should be
fixed to a base so that it stands still. Therefore, the frame or platform is
necessary in order to place the weight measuring equipment. Furthermore, a
load cell needs to be fixed to a base using bolts and nuts. The base is made
out of a hard board, which has been covered with hard cardboard. Once the
connections are made according to the schematic, you are ready to go.

Circuit Explanation:
Schematic and connections are provided below for this project. Pin numbers
8, 9, 10, 11, 12 and 13 of Arduino are connected to 16x2 LCD pins RS, EN,
d4, d5, d6, and d7 respectively. Arduino's A0 and A1 pins are connected
directly to the DT and SCK pins of HX711 Module. Circuit diagrams of the
HX711 module and load cell connections have also been explained earlier.
Working Explanation:

It is easy to execute this Arduino weight measurement project. In advance of


discussing details, this system needs to be calibrated for accurate weight
measurements. A calibration process starts automatically when the system is
powered up. In case the user wishes to calibrate it manually, he or she can use
the push button. The following code describes how we created a void
calibrate() function for calibration purposes.

When calibrating the load cell, wait for the LCD display to appear once 100
grams of load is placed on the cell as demonstrated in the picture below. You
should put the 100g weight over the load cell when the LCD reads "put 100g"
and then wait for it to appear on the LCD. Upon completion of the calibration
procedure, the process will take a few seconds. Any weight can be put over
the load cell after calibration (maximum 40kg) and the calculated value will
appear over the LCD in grams.
Arduino was used to manage the entire process in this project. HX711 Load
Amplifier Module receives the weight signal from the load cell in the form of
an electrical analog voltage. Using the HX711 ADC, a 24bit input signal is
amplified, and then digitally converted into a 24-bit output, which is then fed
to the Arduino. After the data from HX711 has been calculated by Arduino,
the weight values are converted into grams and displayed on LCD. The
calibration of the system is accomplished by pushing a button. In order to
facilitate the process, we created an Arduino program.
29. Automated Plant Irrigation System Using Arduino with Message
Alerts
It is always difficult to leave our plants unattended if we are going out of town
for a few days. Our plants require regular watering. We are making an
Arduino-based Automated Plant Irrigation System, which sends out messages
to you as well as automatically provides water to plants.
Water is provided to the plant through a water pump if the soil moisture level
drops due to a low moisture level detected by the soil moisture sensor. Once
the system detects sufficient soil moisture, it automatically turns off the water
pump. An update on the status of the water pump and soil moisture is sent to
the user whenever the water pump is turned on or off via the GSM module.
Farms, gardens, homes, etc, would benefit all from this system. No human
intervention is required because this system is completely automated.
Required Components for Arduino Plant Watering System Project
Arduino Uno
GSM Module
Transistor BC547 (2)
Connecting wires
16x2 LCD (optional)
Power supply 12v 1A
Relay 12v
Water cooler pump
Soil Moisture Sensor
Resistors (1k, 10k)
Variable Resistor (10k, 100k)
Terminal connector
Voltage Regulator IC LM317
GSM Module:
Using the SIM800 GSM module, we have used it here. Customers as well as
hobbyists can easily embed the SIM800's quad-band GSM/GPRS module.
GSM/GPRS 850/900/1800/1900MHz performance for voice, SMS, data is
provided by SIM900 GSM Module, while SIM800 GSM Module employs an
industry-standard interface. Slim and compact, the SIM800 GSM Module
follows a modern design aesthetic.
Quad - band GSM/GPRS module in small size.
GPRS Enabled
TTL Output
Circuit Explanation:
The homemade soil moisture sensor probe used in this system allows us to
measure moisture levels in the soil. As shown in the following image, a
copper clad board was cut and etched to make the probe. There is a direct
connection between the probe and Vcc, and the other probe terminal is
attached to BC547's base. Sensor sensitivity is adjusted using a potentiometer
connected to the base of the transistor.
This Automatic Plant Watering System is controlled entirely by an Arduino.
Directly connected to the digital pin D7 of Arduino is the soil sensor circuit's
output. The sensor circuit uses a LED, which indicates whether moisture is
present in the soil by its ON state and whether it is not present by its OFF
state.

An SMS can be sent to the user using the GSM module. As you can see, here
we are using a GSM SIM800 card, which is a device that directly gives and
takes TTL signals (to be used by any GSM module). The SIM800 GSM
module is powered by the LM317 voltage regulator. It is recommended to
read the data sheet of the LM317 before using it, since voltage rating is very
sensitive to that. 3.8 to 4.2 volts is its operating voltage rating (please use 3.8
volts when operating it). An example of a circuit diagram for the power
supply of a TTL sim800 GSM module is shown below
A SIM900 TTL Module should be used with 5V, and a SIM900 Module
should be used with 12v in the DC Jack slot on the board.
The 220VAC small water pump is controlled by a 12V Relay. An Arduino
digital pin 11 is connected to the BC547 transistor, which drives the relay.
Status and messages are also displayed on an optional LCD. Several LCD
pins are directly connected to the Arduino, including RS, EN, and D4-D7,
which are directly connected with the Arduino on pins 16, 17, 18 and 19. In
this case, Arduino uses the LCD library built into the board to drive a 4-bit
LCD display.

Working Explanation:
A Plant Irrigation System like this is pretty straightforward in terms of how it
works. The first thing to point out is that the system is completely automated,
and it does not require any manual labor. A GSM module sends alert
messages to the cell phone of the user based on the Arduino's handling of the
entire process.
The Irrigation System with Arduino and a Soil Moisture Sensor is shown on
the following block diagram: When soil contains moisture, conduction occurs
between the two probes of the Soil Moisture sensor, resulting in transistor Q2
remaining in the triggered/on state, and Arduino Pin D7 remaining low. The
Arduino sends the SMS message "Soil Moisture is Normal" when it detects
the LOW signal at D7. The water pump is still in an off state because the
motor switched off.
Transistor Q2 will become off if no moisture is present in soil, and Pin D7
will become high. A message is then sent to the user stating that "Low Soil
Moisture has been detected" and Arduino turns on the water motor. Motor
turned ON”. The soil will automatically turn off the motor when the moisture
content is sufficient.
30. Arduino Motion Detector using PIR Sensor
Many projects have always required motion detection or movement tracking.
With the help of the PIR Sensor, it has become easy to detect movement from
people or animals. This project will demonstrate how a PIR sensor can be
connected to a microcontroller like an Arduino. The Arduino will be
interfaced with a PIR module so that whenever movement is detected, a
buzzer and LED will beep. In order to build this project, you'll need the
following components.
Materials Required:
PIR Sensor Module
Arduino UNO (any version)
LED
Buzzer
Breadboard
Connecting Wires
330-ohm resistor
PIR sensor:
Infrared passive sensors are referred to as PIR sensors. Using this sensor,
humans and animals can be detected without incurring high costs. In addition
to the pyroelectric crystal, the sensor also has a Fresnel lens to enhance the
range of the sensor. A pyroelectric crystal is used to track heat signatures of
living organisms (humans, animals). As shown below, we can also set the
sensor's working by adjusting the options provided by the PIR sensor
modules.

Sensor sensitivity and trigger time of the sensor may be controlled using the
two potentiometers (orange color). It is essentially the Dout pin that is present
between the Vcc and GND pins of the sensor. A 3.3V power supply may also
be used, but the module operates on 3.3V. Additionally, there is a trigger pin
setup on the left side of the module that can be used to make it work in two
different ways. In one mode, the "H" key is pressed and in the other, the "I"
key is pressed.
A person will be detected within range when the Dout output pin goes high
(3.3V) and will go low at a certain time (time is controlled by potentiometer).
It does not matter if the person remains inside the range or has left the area,
the output pin will stay high. In our project, our module is being used in the
"H" mode.
As long as a person remains within the limits of the sensor range, the output
pin Dout will go high (3.3V).
Note:
Depending on your PIR sensor vendor, potentiometers and pins may be
positioned differently. Pinouts can be determined by following the Silk screen
Circuit Diagram and Explanation:

The below image shows the schematic for the Arduino PIR motion detector
project by combining it with an LED/Buzzer and a PIR unit.
Our 5V rail of the Arduino is used to power the PIR sensor. On the Arduino,
the second digital pin is connected to the output pin of the PIR Sensor. The
Arduino INPUT pin will be connected to this pin. A buzzer and LED are then
connected to the 3rd pin of the Arduino. In this case, the output pin of the
Arduino will be used. An output at the 3rd pin will be triggered by an input at
the 2nd pin if an Arduino is programmed to do so.
31. Interfacing Hall Effect Sensor with Arduino
The use of sensors has always been crucial to any project. It is these that
create the digital/variable data that is used by electronics to process the real-
time environmental data. The market offers many types of sensors, and you
can choose one that suits your needs. We will use an Arduino to create a
project that uses Hall sensors, also known as Hall effect sensors. Using the
magnet sensor, you can determine the magnet's pole as well as detect its
magnetic field.
Magnets are detected for what reason? Perhaps you'd like to know. Actually,
there are a number of applications that use Hall Effect sensors, but most of us
probably are unaware of them. The speed of rotating machines or bicycles can
be measured using this sensor. BLDC motors also utilize this sensor to track
the Rotor Magnet position and immediately activate the Stator coils
accordingly. Let's learn how to add another tool to our arsenal by learning
how to interface Hall effect sensors with Arduino. Some projects involving
Hall sensors are as follows:
As part of this tutorial, we will utilize Arduino interrupts to detect a magnet
near a Hall sensor and flash an LED. We will use interrupts in our tutorial as
well, since Hall sensors will typically only be used with interrupts due to
their applications that require high reading and executing speeds.
Materials Required:
Hall Effect Sensor (any digital version)
Arduino (Any version)
10k ohm and 1K ohm Resistor
LED
Connecting Wires
Hall Effect Sensors:
Several things should be kept in mind before we dive into the connections for
Hall Effect sensors. Digital Hall sensors and Analog Hall sensors are the two
main types of Hall sensors. As opposed to the digital Hall sensor, which
detects whether a magnet is present or not (0 or 1). The analog Hall sensor, on
the other hand, can detect the strength of or the distance from the magnet,
based on its output. Because these are the most common digital Hall sensors,
this project will only focus on them.
By its name, Hall Effect sensors work on the basis of the "Hall Effect".
Having carried out this experiment the law states that when current flows
perpendicular to the direction that the current is flowing, a voltage can be
measured at the angle at which the current flows. It will be possible for the
hall sensor to detect magnets around it using this technique. I'm done with
theory, let's move onto hardware.
Circuit Diagram and Explanation:

This circuit diagram demonstrates how to connect a Hall sensor to an


Arduino.

This Arduino circuit diagram for a Hall Effect sensor is quite straightforward
as you can see. It is when we try to figure out hall sensor pin numbers that we
usually make mistakes. When positioned face-on, the Vcc and Ground pins are
on the left, followed by the Signal pin.
As we mentioned earlier, we will use interrupts, which is why pin 2 of the
Arduino is connected to the output pin of the Hall sensor. Magnets are
detected by switching on the Pin, which is connected to an LED.
Arduino Hall Effect Sensor Working:
You can now upload the Arduino code once you have created your code and
hardware. A 9V battery has been used to power the entire setup. Power can
be provided by any preferred source. You will see the LED light up as soon
as you place the magnet close to the sensor and it will turn off as soon as you
remove the magnet.
Note:
Hall sensors are pole sensitive, which means that each side of the sensor can
either detect only the North Pole or only the South Pole, only one side of the
sensor can detect both poles. Thus, if you bring the north sensing surface close
to the south pole, the LED will not glow.
Throughout the sensor, we bring the magnet near to it, causing it to change its
state when we do that. An interrupt pin is triggered by this change, which then
calls the toggle function, which changes the variable "state" from 0 to 1. In
this way, the LED will illuminate.
Once the magnet is moved away from the sensor, the sensor output will again
change. We notice that this changes again by using an interrupt statement and
thus the variable "state" is set to zero. The LED will darken if the switch is
turned off. Each time you approach the sensor with a magnet, the same
happens.

32. Smart Blind Stick using Arduino


Has Hugh Herr ever caught your attention? His disability has not held him
back; he is a staunch believer in the ability of technology to provide the same
opportunities for disabled people as the able-bodied. Herr said in a TED talk
that human do not have disabilities. There is no such thing as a broken person.
We have a broken and disabled built environment and technology. Through
technological innovation, we the people do not have to accept our limitations
and can transfer them. In truth, he was living his life by these words, today he
wears prosthetics to walk and claims a normal existence. Therefore,
technology does indeed have the ability to neutralize human disability. With
this in mind, let's build a blind man's stick that can do more than just assist the
visually impaired.
Its ultrasonic sensor will detect the distance from an obstacle, its LDR will
detect lighting conditions, and its RF remote will allow the blind man to find
his stick remotely. Using a Buzzer, all feedback will be given to the blind
man. The buzzer can certainly be replaced with a vibrating motor and you can
advance a lot further using creativity.
Materials Required:
Arduino Nano (Any version will work)
Ultrasonic Sensor HC-SR04
LDR, Buzzer and LED, 7805
433MHz RF transmitter and receiver
Resistors, Capacitors
Push button, Perf board
Soldering Kit, 9V batteries
Circuit Diagram:
Two separate circuits are required for this Arduino Smart Blind Stick Project.
It consists of the main circuit, which is mounted on the stick by the blind man.
There will also be a small relay for locating the main circuit, which is an RF
transmitter. As seen in the following circuit diagram, the main board consists
of:

As can be seen, all the sensors are controlled by an Arduino Nano. With a
7805-voltage regulator, a 9V battery provides power to the entire board.
Powered by 5 volts, the Ultrasonic sensor's trigger and echo pins are
connected to the Arduino nano's pins 3 and 2 as shown in above diagram.
LDRs are connected to resistors of 10K, creating a potential divider, whose
differential voltages are read using Arduino ADC pin A1. Reading the RF
receiver signal from A0 is done using the ADC pin. Pin 12 of the board is
connected to the buzzer, which provides the board's output.
The goal of this project was to develop an ultrasonic blind walking stick that
utilized Arduino. There are 30 million permanently blind people and 285
billion people with some form of vision impairment according to WHO.
As soon as you notice them, you will realize that they are unable to walk
without the assistance of someone else. They require assistance to get to their
destination. As a result, they have more challenges to face in everyday life.
Blind sticks allow people to walk with greater confidence. In this stick, the
object in front of the person is detected and a response is given either through
vibrations or commands. This allows the individual to walk fearlessly. We
can help them overcome their difficulties with this device.
Below is a circuit diagram of the RF remote. The workings of this system are
also discussed.

Fig. RF transmitter Circuit


I have modified a remote-control circuit to make it function using a small
hack. It usually takes two MCUs or an encoder and decoder to use this 433
MHz module. We rely on the receiver and transmitter to detect if any signals
are being transmitted in our application. Thus, ground or Vcc is connected to
the Data pin of the transmitter.
An RC filter is used to pass the data pin from the receiver to the Arduino. The
example below illustrates this. Now, the Receiver continually outputs the
same ADC value whenever the button is pressed. It is impossible to observe
this repetition without pressing the button. To detect whether the button has
been pressed, we write an Arduino program that checks for repeated values.
Therefore, that is how Blind people can track their sticks. You can learn about
how RF transmitters and receivers work by visiting this page.
All connections were soldered using a perf board so that it would be intact
with the stick. A breadboard can also be used to make them.
33. Arduino Metal Detector
Metal Detectors are used in various places to detect metals that are
dangerous, such as airports, shopping malls, cinemas, etc. We have previously
made a very simple Metal detector without a microcontroller; now we
incorporate an Arduino to make the Metal Detector. The coil and capacitor
that will be used in this project will be responsible for detecting metals. We
have built this metal detector project using an Arduino Nano. All electronics
lovers should find this project very interesting. A very loud buzzer will start
beeping the moment the metal detector detects it.

Required Components:
Arduino (any)
Coil
10nF capacitor
Buzzer
The 1k resistor
330-ohm resistor
LED
1N4148 diode
Breadboard or PCB
Connecting jumper wire
9v Battery
Working Concept:
Any time there is current passing through the coil, a magnetic field is
generated around it. Magnetic fields generate electric fields when they are
changed. The Faraday Law states that due to the Electric field, a voltage is
generated across the coil that opposes the change in magnetic field. The result
is an increase in current, causing the voltage to oppose the change in magnetic
field. The Inductance value is measured in Henrys using the following formula

L = (μο * N2 * A) / l
Were,
L- Inductance in Henries
μο- Permeability, its 4π*10-7 for Air
N- Number of turns
A- Inner Core Area (πr2) in m2
l- Length of the Coil in meters
Any metal that comes into contact with the coil causes the coil to change its
inductance. The type of metal determines the change in inductance. Non-
magnetic metals have a smaller magnetic moment, while iron has a greater
magnetic moment.
Inductance value changes drastically depending on the core of the coil. As you
can see in the figure below, the inductors have an air-cored core, so there is
no solid core in these inductors. This is basically just a lot of coils lying
around. No matter what the inductor generates, its magnetic field flows in
nothing or air. Inductors with low inductances are used in these applications.

When the values of a few microHenry are required, these inductors are used.
If your value is greater than a few milliHenry, then this is not the right choice.
An inductor with ferrite core can be seen in the figure below. Despite the
large inductance values of these Ferrite Core inductors.

In this case, the coil wound within the inductor is air cored, so when a metal
object is brought to the coil it serves as a core. Inductance of the coil changes
or increases greatly when this metal acts as a core. By adding a metal piece to
the LC circuit, a significant amount of inductance is introduced, altering the
overall impedance or reactants of the circuit.
In this Arduino Metal Detector Project, we need to figure out how to detect
metals by measuring the inductance of the coil. Thus, we did this by using the
LR circuits (Resistor-Inductor Circuits) that we described previously. A coil
with about 20 turns has been used here with a winding of around 10 cm in
diameter. A tape roll has been used to wind up wire on, and the wire has been
wound around it.
Metal Detectors are used to detect land mines, detect weapons such as knives
and guns at airport security checkpoints, conduct geophysical prospecting,
archaeology and treasure hunting.
Circuit Diagram:

The whole Metal Detector Project has been controlled by an Arduino Nano.
Indicators such as LEDs and buzzers are used for metal detection. For the
detection of metals, coils and capacitors are used. Reduced voltage is also
achieved by using a signal diode. Additionally, a resistor is used to limit the
current flowing through the Arduino pin.
Working Explanation:
The metal detector on this Arduino is a little challenging to use. The high pass
filter of the LR is fed the block wave or pulse generated by the Arduino.
Therefore, each transition will be marked by short spikes caused by the coil.
Having a coil with a high inductance result in pulses with a shorter pulse
length. We can measure the inductance of a coil with the help of these shock
pulses. Due to the very short duration of the spikes (approx. 0.5
microseconds), it is very difficult to successfully measure inductance with
that.
The capacitor we used instead of this, is charged by rising impulses or spikes.
The capacitor was charged with a few pulses so that A5 on the Arduino can
read its voltage. This capacitor's voltage is read using ADC by Arduino. Cap
Pin was made the output pin as soon as the voltage was read and set to low,
quickly discharging the capacitor. About 200 microseconds are required to
complete this process. The measurement was repeated and the resulting
average was taken to produce the best results. Using that method, we can
calculate Coil's approximate inductance. Using the result, we transfer the data
to LED and buzzers to see whether metal is present. The complete code that
follows this article will help you understand how the program works.
At the end of this article, you will find the full Arduino code. We will use two
Arduino pins in this project, one to generate block waves that will be fed into
the coil, and the second to read voltage from the capacitor. We have also
connected LEDs and buzzers to two other Arduino pins besides these two.
34. An introduction to Brushless DC Motors (BLDC) and
how to control them on an Arduino
We have always enjoyed building things and getting them to work as we
wanted. It would definitely be an anxiety pump for hobbyists and hardware
tinkerers to build something that could fly. Absolutely! Among the various
aircraft I refer to are gliders, helicopters, planes, and primarily multi-copter
aircraft. Due to the community support available online today, it has become
very easy to build one on your own. The BLDC motor is a feature common to
all things that fly, but what is it? What is the purpose of it in order to fly? How
does it differ from other software? Is there a way you can interface your motor
with your controller and buy the right motor? What are ESCs and why do we
need them? These are just a few questions you can get answered in this
tutorial.
The main purpose of this tutorial is to control the speed of a 2112/13T
sensorless BLDC outrunner motor (commonly found in drones), using an ESC
(Electronic Speed Controller).
Materials Required
A2212/13T BLDC Motor
ESC (20A)
Power Source (12V 20A)
Arduino
Potentiometer
Understanding BLDC Motors
BLDC motors operate smoothly, which makes them common in ceiling fans
and electric vehicles. BLDC motors, on the other hand, are equipped with
three wires, thus forming three phases. Hold on... what!!??
BLDC motors still operate by using pulsed waves, though they are classified
as DC motors. The DC voltage from the battery is converted into pulses by the
electronic speed controller (ESC), and the motor receives the pulses via its
three wires. Current can only enter and leave the motor through two phases at
a given time, so that one phase powers the motor and the other phase delivers
power.
When the motor is in this position, the coil inside is energized, and therefore
the magnet on the rotor aligns itself with the energized coil. A motor is rotated
by energizing the next two wires and then turning them by the ESC. In order to
function, the coils need to be energized according to their order of
energization and their speed depends on its speed. The remainder of this
article will discuss ESC in greater detail.
A BLDC motor can be classified in several ways, some of which are more
common than others.
A BLDC motor can be installed in the in-runner or out-runner: In runner
BLDC motors work just like any other motor. In other words, the motor shaft
rotates, but the casing is stationary. BLDC motors with outrunners are the
opposite in that the coil inside remains fixed while the casing rotates along
with the shaft. A major advantage to the use of out-runner motors is that the
outer part of the motor (the one that rotates) turns into the tyre rim, so it is not
necessary to have a coupling mechanism. A motor without runners tends to
have more torque than those with in runners, which makes them a best choice
for EVs and drones. Also, the one we are using here is an outrunner type.
Note:
For the sake of this tutorial, let's skip a different type of motor called the
coreless BLDC motors, which are also used for pocket drones. They work on
a completely different principle, so we'll skip it for now.
Sensorless and sensor-loaded BLDC Motors: To ensure continuous rotation of
a BLDC motor, feedback must be provided. That is, the ESC must know
which magnets are where and on which pole in order to power the stator
appropriately. An inside hall sensor can be used to obtain this information, or
the motor can also be left open to collect this information. ESC receives the
information from the hall sensor about the magnet.
Motors like this are used in electric vehicles and are known as sensors-based
BLDC motors. Second, we can use the back EMF generated by the coils when
the magnets cross over them. This method does not require any additional
hardware or wires; the phase wire itself is a feedback mechanism for
measuring back EMF. We use this method in our motors, as well as in drones
and other flying projects.
Why do Drones and other multi-copters use BLDC Motors?
Drones come in many forms, from quadcopters to helicopters and gliders, all
of which have one thing in common: hardware. What are BLDC motors? Why
do they exist? Compared to DC Motors, what is the purpose of using BLDC
motors, which are a bit more expensive?

One important reason for this is the very high torque generated by these
motors, which is important for gaining thrust or losing thrust rapidly in order
to launch or land a drone. As well as having these motors as out runners, they
are offered as out runners as well, enhancing their thrust. Our drone will stay
steady in mid-air due to the smooth vibration less operation of the BLDC
motor.
BLDC motors have a powerful to light weight ratio. In order for drones to
perform well, they need motors that are both powerful (high speed and torque)
and lightweight. In order to match the performance and torque of a BLDC
motor with a DC motor, the motor would have to be twice as heavy.
Why do we need an ESC and what is its function?
In order to generate the phases for BLDC motors, DC voltage from the battery
has to be converted to pulses using a controller. The term Electronic Speed
Controller refers to this device. Controllers have the role of energizing the
phase wires so that the BLDC motors rotate. To do this, the coil is energized
when the magnet crosses the wire and the back EMF is detected. It is beyond
the scope of this tutorial to investigate all the hardware brilliance found in the
ESC. The speed controller and the battery eliminator are a few other features.

Speed control using PWM: The ESC can read the PWM signal connected to
the orange wire to control the speed of the BLDC motor. This motor functions
very much like servo motors, the pulse width modulation signal provides a
20ms period, and the duty cycle may be varied to vary the motor's speed. Our
Arduino program can utilize the same servo library to control the position
since the same logic applies to the servo motors. Here's how you can use
Servo with Arduino.
Battery Elimination Circuit: Almost all ESCs feature a Battery Elimination
Circuit (BEC). This circuit eliminates the need for a separate battery for the
microcontroller; it will provide a regulated +5V to the Arduino, so there is no
need for a separate power supply. It is normal for this voltage to be regulated
by one of a number of circuits, and on cheap ESCs, you'll usually hear linear
regulation, but there are also ones that use switching circuits.
Every ESC comes with a firmware program installed by the manufacturer. In
terms of ESC firmware, traditional firmware, Simon-K, and BL-Heli are
some of the more popular options. As we mentioned earlier, this firmware can
also be customized by users, but we won't go into too much detail about this in
this tutorial.
Arduino BLDC Motor Control Circuit Diagram

BLDC motors can be easily connected to Arduinos via a straightforward


interface. A minimum 12V and 5A source of power is required for the ESC.
My RPS has been used in this tutorial, but you can also use a Li-Po battery
because it's just as powerful. Connect the three phase wires of the ESC to the
three phase wires of the motors, there is no specific order in which the wires
should be connected, you can connect them in any order.
Controlling BLDC Motor with Arduino
The circuit diagram should be followed and the code uploaded to the
Arduino. The ESC should be powered up.
Make sure you mount the BLDC motors securely, or they will jump around
when they are rotating. In the event that the throttle signal is not within the
threshold limits within a few seconds after you start your setup, your ESC
will make a welcoming tone and keep beeping. The beeping tone will stop
when the POT from zero is gradually increased. The motor will start spinning
more slowly as you increase the PWM signal beyond the lower threshold
value. Once the voltage reaches the upper threshold limit, the motor will stop
due to a lack of power. The more voltage you provide, the more speed you
will see. Once you have completed the process, you can repeat it.
35. Automatic Medicine Reminder Using Arduino
It is always our intention to keep our dear ones in good shape when it comes
to health. The question is, what will happen when people get ill and forget to
take their medications.

Right? We'd be concerned, wouldn't we? Hospital patients need to be


reminded to take their medicine on time, but it's difficult to do so because
there are so many of them. To remind people to take their medicine on time,
the traditional methods require human effort. Machines can perform that task
in the digital era and we aren't bound by those rules. Besides doctors in
hospitals and patients at home, Smart Medicine Reminder has many other
uses.
When it comes to reminding, there can be many ways to remind it:
Show it on a display
Send notification on email or Phone
Using mobile apps
Buzz alarm
Using Bluetooth/ Wi-Fi
Get a call
Remind for next medicine time while reminding current time
Depending on the circumstances, we can combine different methods. Our
Medicine Reminder has a simple Arduino circuit that reminds us to take our
medicines 1 or 2 or 3 times a day. Push buttons allow you to select a time slot.
Additionally, it displays the current date and time. This article will be further
extended into an IoT project, where a notification will be sent by email or
SMS to users. Patient Monitoring Systems can also be used to send
medication reminders.
Arduino Medicine Reminder Circuit Diagram and Connections
Remembering to take medications may seem like an unnecessary task, but we
cannot emphasize its importance enough. Most seniors are prescribed
medication to manage illness due to increased visits to the doctor and
hospital. Many of the patients find it difficult to remember to take their
medication and not just because of their hectic schedules. Some patients have
trouble adhering to their medication regimen because of memory loss.
Our loved one's health and quality of life depend on making sure they follow
their doctor's orders for prescribed medications. One small change can make
all the difference in the effectiveness of a health care plan.
We value patient's health and ensure he or she takes their medication properly.
To facilitate this, this project and caregivers are standing by to encourage
your loved one to take their medications on time.
Components Required
Arduino Uno (We can use other Arduino boards also, like Promini,
Nano)
RTC DS3231 module
16x2 LCD Display
Buzzer, LED (any color)
Breadboard
Push Buttons
10K Potentiometer
10K,1K Resistors
Jumper Wires
The DS3231 RTC is interfaced with Arduino Uno over I2C protocol in this
Medicine Reminder Project. Also, you can use an RTC IC DS1307 with
Arduino to read the time. Also included with the RTC DS3231 is a 32k
memory that may be used to store additional information. The RTC module
requires 3.3V to be powered from the Arduino uno.

The LCD display occupies a 16x2 area, and it is connected using SPI. It is
common for buzzers to be used to remind people before taking medication.
Each push button features a distinct feature that allows it to be selected. It
brings up a reminder to take your medication once a day using the first push
button. There is a second button for reminding twice a day, and a third for
reminding three times a day. Once a user has heard the alert, they can press the
fourth push button to turn off the buzzer.
Working of Automatic Medicine Reminder System
In order to power the Pill Reminder Alarm, 5V is required. When Circuit
Digest is first launched, it displays the welcome message "Welcome to Circuit
Digest". Three screens are displayed on the LCD screen at a time. As soon as
the screen loads, a message appears saying "Stay Healthy, Get Well Soon". On
the next screen, a help screen is displayed that instructs you how to choose a
time-slot to remember (once, twice, or three times per day). A time slot can
be configured in the program in accordance with the user's preference. The
duration has now been reduced to three, which are 8am, 2pm, and 8pm.
There are three modes of dividing up the time slots. When the user presses the
first push button, the user is instructed to take medicine once a day at 8am.
When the user presses the second push button in mode 2, the system selects to
take medicine twice daily at 8am and 8pm. In Mode 3, when the third push
button is pressed, the user will take their medication three times daily at 8am,
2pm and 8pm.
Additionally, the buzzer can be snoozed for a period of ten minutes (not
included in this project). Push buttons allow the user to choose desired slots,
and a RTC is used to determine the current time. The buzzer starts to buzz
when the time matches the selected time slot. Users have the option of
stopping the buzzer by pressing the STOP button. Similarly, the next reminder
is sent by the same method.
Summary
The following chapter should be quite interesting to you, and we presume that
you have learnt more than 20 project as they will be useful to you in building
your dream project. In upcoming sessions, we will cover How to
Troubleshoot and Fix Arduino Issues as well as how to repurpose your old
Arduino.
CHAPTER 6
How to Troubleshoot and Fix Arduino Issues

There are times when your Arduino program and your hardware won't
function as expected. There are a number of causes to this problem, including
software or hardware incompatibility. Using this section, you can
troubleshoot Arduino or ESP8266 and solve hardware and software related
problems.

Can’t Load Programs on Arduino

The right board should make it easy for you to load programs once the
computer program is configured correctly. There are several reasons for why
codes cannot be loaded into the system.
An unknown problem may result from using the incorrect port, using the
wrong drivers, or missing the right drivers. Physical connection problems or
issues with the device's firmware can give rise to hardware problems.
Solution: Verify that the board model is compatible with the configured
model
As a first solution, you should confirm that you have configured the Arduino
model on the program properly. The program's users often select the
incorrect board type. If you haven't already done so, verify the model used
within the Arduino software by going to Tools > Board. You can then reload
the code to see if it was loaded when you selected the right board type.
Also, make sure the board has the right type of microcontroller. Many
Arduino boards, particularly the older ones, feature the ATmega160
microcontroller. In the newer models, an ATmega328 is used. Look at the
board's microcontroller and choose it on the device if you aren't sure which
one to select.
There are also many reasons why the code can't be loaded, such as driver
issues. Make sure the serial port driver is installed by going to Tools >
Serial Port. Make sure to verify this information with a computer connected
to the board.
Your computer's device manager is another place to look. Identify any items
in the device that are marked yellow or unidentified. It might be the Arduino-
specific driver that is causing the problem if you are unaware of the drivers
that are causing the problem. If you need to install a new driver, you can
access its properties and install it by accessing its driver installation tab.
Review the previous chapter for more information about installing drivers.
Solution: Ensure a Functioning Arduino

When the device isn't powered, it may not be detected by your computer. By
viewing its LED, you can determine whether the board itself is receiving
power. There must be some sort of problem with the electric system if it isn't
working. Check the power supply source to see if it's functioning.

Those boards with dual power options need to be set to receive power from
the appropriate source. In the case of USB power, look for a jumper
direction that points towards the side of the USB connector, which means the
system should be powered by this connector. To fix it, re-plug it after
disconnecting it, setting the jumper to ground, and resetting it to power. The
LED indicator should turn on to let you know if it is functioning.

Solution: Reset the Device


Arduino boards come with a reset button, which can be useful if you run into
problems loading codes. By pressing the reset button, the board can be reset.
Hold the button down for several seconds and then reset it. If it doesn't work
after waiting for a few minutes, reload the program.

Solution: Diagnose USB Connection Problem


In most cases, the inconsistency is caused by the hardware itself. If the data
pathway itself is down, the code transfer will not be completed. Change your
USB cable to solve this problem. Diagnosis of the cable problem can be
done in a variety of ways. The board may not be detected if it is plugged into
your computer with the wrong cable. Verify through the Arduino program
whether or not your board has the serial port that should be assigned.

Arduino Software is Not Working

There are times when programs don't perform as expected. Arduino


software that doesn't load correctly has probably been installed on
the computer with an outdated or incorrect version compared to what
the operating system requires. A computer program should not be
installed if it is incompatible with your system. For this case, you
should uninstall the program, download a newer installer, and
reinstall.

There's also the possibility that you're using a third-party Arduino


program. Programs developed by third parties should work as
advertised by Arduino developers. Install the new third-party
application after uninstalling the current one

The official website of the developer. Downloading a file from


another source is not recommended. Installation is as simple as
extracting and installing.

If the previous solution does not work, you can download the
Arduino program. Upon installing the program, make sure it is
loaded

Arduino Software is Freezing and Crashing


It is caused by a program inconsistency that causes Arduino software to
freeze. Programs installed with peripherals, drivers, or other files can
conflict with conflicting programs. By using MS-Config, identify likely
conflicting programs. Disable Start-up programs and services by loading this
utility. Load Arduino software and restart your computer. You might have an
issue with one of your starts up programs, even if the Arduino program
loaded flawlessly. Identify the cause of the problem by testing each program
and service. The result will be necessary to prevent lagging before you can
load Arduino software.
Although the program does not freeze or crash, sometimes it runs slowly.
Additionally, a device on your computer may be causing this issue. It is most
commonly caused by installation of the COM port interfering with loading.
To troubleshoot and disable program causes, use MS-Config again. Connect
all of your computers' other devices to your computer before turning it off.
Connect the device to the computer once it has been turned on. Try opening
the program and taking a look at how it responds.

Don’t Throw Damaged Arduino

Beginners have a high risk of damaging an Arduino PCB q43. This is part of
the learning process, so don't worry about it.
Never discard a board after it has been damaged. It still has value as a way
for you to become familiar with its components. In order to understand how
its parts are assembled, it's recommended that you take it apart. When you
are ready to build a custom board, this information will come in handy.
Essential Resources

1. Arduino Official Home Page https://www.arduino.cc/ Info on


hardware, some libraries for sensors, the integrated development
environment (IDE) and reference material on commands and
structures
2. www.instructables.com : Info on DIY projects prepared by others
3. Arduino Official Project Pages https://create.arduino.cc/projecthub
4. https://learn.adafruit.com Adafruit makes many shields and sensors,
and they have tutorials for almost everything they carry
5. http://www.arduinoclassroom.com/index.php/arduino-101 Arduino
Classroom is currently doing an intro series on Arduinos. Check it
for updates and more topics in the future
6. http://playground.arduino.cc/ Arduino playground is the wiki run by
the Arduino Company for its products. There is a lot of helpful
information on almost everything imaginable here.
7. Github Arduino Page
https://github.com/arduino/Arduino
8. Hackster Arduino Page
https://www.hackster.io/arduino
9. Hackster Arduino Projects https://www.hackster.io/arduino/projects
10. Circuit digest Arduino Projects https://circuitdigest.com/arduino-
projects
11. Electronics Hub Arduino Project Ideas
https://www.electronicshub.org/arduino-project-ideas/
12. Electronics for u Arduino Project Ideas
https://www.electronicsforu.com/arduino-projects-ideas
13. Home of Make Magazine, which has lots of Arduino projects
www.makezine.com
14. Arduino Projects by All about circuits dot com
https://www.allaboutcircuits.com/projects/category/arduino
15. Arduino Projects by How to mechatronics dot com
https://howtomechatronics.com/arduino-projects/
16. Arduino Official YouTube Channel
https://www.youtube.com/c/Arduino/videos
Bibliography

[1]. Arduino official web site https://www.arduino.cc/


[2]. Exploring Arduino: Tools and Techniques for Engineering Wizardry; 2nd
Ed; Jeremy Blum; Wiley; 512 pages; 2019;
[3]. Fritzing. Project web site: http://fritzing.org/
[4]. Programming Arduino Next Steps: Going Further with Sketches; 2nd Ed;
Simon Monk; McGraw-Hill Education; 320 pages; 2018;
[5]. Arduino. Project web site: https://www.arduino.cc
[6]. J. Fraden. Handbook of modern sensors. Springer Verlag, Berlin, third
edition, 2004.
[7]. Hackster Arduino Page https://www.hackster.io/arduino
[8]. Arduino Workshop: A Hands-On Introduction with 65 Projects; 1st Ed;
John Boxall; No Starch Press; 392 pages; 2013;
[9]. Circuit digest Arduino Projects https://circuitdigest.com/arduino-
projects
[10]. Arduino For Dummies; 2nd Ed; John Nussey; John Wiley & Sons; 400
pages; 2018;
[11]. Arduino Official YouTube Channel
https://www.youtube.com/c/Arduino/videos
[12]. Make: Getting Started with Arduino; 3rd Ed; Massimo Banzi, Michael
Shiloh; Make Community; 262 pages; 2014;
[13]. Hackster Arduino Page https://www.hackster.io/arduino
[14]. Programming Arduino: Getting Started With Sketches; 2nd Ed;
[15]. Electronics for u Arduino Project Ideas
https://www.electronicsforu.com/arduino-projects-ideas
[16]. Simon Monk; McGraw-Hill Education; 192 pages; 2016
[17]. Circuit digest Arduino Projects https://circuitdigest.com/arduino-
projects
[18]. Beginning C for Arduino: Learn C Programming for the Arduino; 2nd
Ed; Jack Purdum; Apress; 388 pages; 2015;
[19]. Github Arduino Page https://github.com/arduino/Arduino
[20]. Electronics Hub Arduino Project Ideas
https://www.electronicshub.org/arduino-project-ideas/
[21]. Hackster Arduino Projects https://www.hackster.io/arduino/projects
[22]. Arduino: A Quick Start Guide; 2nd Ed; Maik Schmidt; Pragmatic
Bookshelf; Pragmatic Bookshelf; 323 pages; 2015;
[23]. Home of Make Magazine, which has lots of Arduino projects
www.makezine.com
[24]. Arduino Projects by How to mechatronics dot com
https://howtomechatronics.com/arduino-projects/
[25]. Make: Sensors; 1st Ed; Tero Karvinen, Kimmo Karvinen, Ville
Valtokari; Make Community; 400 pages; 2014;
ABOUT THE AUTHOR

Arsath Natheem is an Indian Biomedical Engineer and YouTuber


who works primarily in the field of Data Science, He is best known for his
multimedia presentation regard "How Biomedical Engineers Save the lives"
displayed at VCET in Tamilnadu, he was honored best project award for
Human Interaction Intelligence Robot as Personal Assistance, and IoT Based
Voice Recognition Robot for defenses, also presented his project at
Adhiyamaan CET and won the first prize. He participated project
competition at Madras institute of technology (MIT) in Chennai, He
completed his Undergraduate Degree at VCET, and He Enthusiast in R&D at
Data Science and Online Content Creation, now he working on Amazon as a
Self-Publishing Author and Technical Writer.
.
ONE LAST THING…
If you enjoyed this book or found it useful, I’d be very grateful if you’d post a
short review on Amazon. Your support really does make a difference and I
read all the reviews personally so I can get your feedback and make this
book even better.
If you’d like to leave a review, then all you need to do is click the review
link on this book’s page on Amazon.com
Thanks again for your support

You might also like