Professional Documents
Culture Documents
To Arduino For Everyone PDF
To Arduino For Everyone PDF
TECHNOLOGY
YOUR HANDY GUIDE TO EVERYDAY
To
Arduino
tm
for EvEryonE
Arduino™
for
everyone
powered by
Chapters
Arduino™ for everyone
decemBER 2014
05PAGE
Imagine...
An introduction to help you visualize the world in the near future
thanks to revolution in the field of electronics that is taking place today.
09 PAGE
Internet of Things
The next step towards the evolution of technology − i.e. ‘the Internet
of Things’ − with some examples that demonstrate its usefulness and
the driving force behind this booklet.
13 PAGE
Microcontroller: An integrated
processor
The inspiration for embedded systems − the microcontroller − along
with its comparison to the microprocessors present in our computers.
The microcontroller can be called the brain of the Arduino™ platform.
20 PAGE
Arduino™: A simplified open source
microcontroller
This chapter introduces you to the Arduino™ programming platform,
the various Arduino™ products available in the market, and outlines
how to select the right one for you.
40PAGE
Arduino™ Add-ons: Shield
Lets examine add-on hardware called ‘Shields’ that extends the
capabilities of the Arduino™ platform and simplifies using Arduino™ for
specialised tasks (without burning anything).
46PAGE
Sketching the code
Basic programs that are necessary to program the Arduino™ platform
and the add-on hardware, Shield.
72 PAGE
Applications of Arduino™
We’ll jump into a few simple do-it-yourself (DIY) projects in detail and
provides some inspiration by pointing out to various projects that are
available online.
80 PAGE
Advanced Hardware
Learn about about more advanced hardware already available or soon
to be introduced for use by engineers and budding engineers.
91 PAGE
Primer to Electronics
You’ll be exposed to a few details related to electronic hardware design
and tips that need to be kept in mind for everything to work perfectly.
We recommend that even the experts read this, lest you abandon ship
on the last leg of your hardware design journey, due to one incorrect
connection on the circuit board.
Volume 09 | Issue 12
TECHNOLOGY
YOUR HANDY GUIDE TO EVERYDAY
To
Published by 9.9 Mediaworx
Arduino
tm
book are by Arduino™ and are covered under the CC BY-SA license.
December 2014
Free with Digit. If you have paid to buy this Fast Track from any Imagine the future
An army of devices
source other than 9.9 Mediaworx Pvt. Ltd., please write to Microcontroller: An
Free With Digit December 2014
integrated processor
Arduino™: A simplified
editor@digit.in with details open source microcontroller
Arduino™ addons: Shield
Sketching the code
Applications
Advanced hardware
Imagine...
Your devices could talk to you in the
near future. The concept of the Internet
of Things is already here and will soon
be enmeshed in our day-to-day lives
Scenario 1
Imagine getting this email while at lunch, office or out shopping:
From: home@hivemind.in
To: me
Time: 1:54:45 PM
Subject: Your plant here. I need water.
6 Imagine...
Body:
Plant: The soil is getting dry. I need water.
Water tank: The water tank is half filled.
Temperature: Phew! It’s 37oC.
Humidity: 61%
Might sound crazy to some
of you, but this could be our
world in the near future. While
plants can’t currently commu-
nicate with us, technological
advances can enable them to do
so with our assistance by moni-
toring and helping them survive
the changing conditions. On a
grander scale, we can expect
better agricultural produce from
our farms.
Let’s come back to that pre-
sumably from the future email
you just received. You look at
Thirsty plant asking for water the various kinds of information
provided and decide to water the
plant. Based on the temperature, humidity and time of sent email (many
hours before sunset), you may decide to water all the plants for 10 minutes.
But wait a minute…the water tank is half filled. So you finally decide to water
for six minutes or until the soil is moist and save some water for later use.
To do this, you send a reply.
To: home@hivemind.in
From: me
Time: 1:56:20 PM
Subject: Re: Your plant here. I need water.
Body:
Plant: Water 6 minutes or till moist, whichever is less.
So you send a reply that looks like an email you’d send to your mobile
company to activate the internet service, request to start (or stop − as more
likely in India) a value added service or may be to vote for your favourite
contestant in some reality show.
Imagine... 7
You arrived at the decision not simply based on some arbitrary percep-
tion of what should be done, but based on the surrounding environment
(temperature, humidity, soil moisture, etc.) and the amount of water in the
water tank.
How did you get all this information?
You had various sensors installed to automate parts of your home: a
water sensor to pump water into the overhead tank, soil moisture sensor
to check for low moisture condition, temperature and humidity sensor to
keep your home at comfortable temperature and moisture level. Also, the
email had an in-built time stamp that helped to decide on the time left for
sunset. You programmed your home to send all the necessary data for you
to be able to take an informed decision.
It’s also possible to automate the decision-making part and inform you
about the decision taken. You could then either modify the automatically
taken decision or let it happen.
Scenario 2
You’re on your way home and,
let’s say, 30 minutes away from
reaching there. Leaving the AC
on all day will lead to power
wastage. So you send the fol-
lowing email:
To: home@hivemind.in
From: me
Time: 7:20:39 PM Hardware to sense current temperature
Subject: AC
Body:
Home: Reaching in 30 minutes
AC: 26oC after 30 minutes
You get this reply:
To: me
From: home@hivemind.in
Time: 7:21:45 PM
Subject: Re: AC
Body:
Home: Your parents will reach in 45 minutes
AC: Parents’ request for 28oC in 45 minutes
8 Imagine...
You reply:
To: home@hivemind.in
From: me
Time: 7:23:46 PM
Subject: Re: Re: AC
Body:
Home: Reaching in 30 minutes
AC: 26oC after 30 minutes
AC: 28oC after 45 minutes
This way you can comfortably set the temperature during your commute
and enjoy coolness at your home when you actually reach there.
Email is just one way to achieve this. A similar exchange of information
could also happen via a text message.
Alternatively, since internet-connected smartphones are on the rise,
all you may need to do is launch an app and check the temperature of
your house. You can then set the time you’ll reach home and the required
temperature.
Internet
of Things
An army of interconnected devices
is headed our way and will soon
be controlling our world.
T
he concept inspiring this interconnectivity is called the “Internet
of Things” and is a work in progress by many developers of tech-
nology across the world. These are the folks who will help us make
the world a better place to live in by building smart cities with
smart buildings, smart street lighting systems and many such innovations.
10 Internet of Things
Convenience by
automation
Let’s take another case.
You’re out of town for
some reason and will be
reaching home late. How-
ever, a relative is coming
over to your house when
you’re not there. Even
Future smart highways though you’re outside,
you could just authorise
the person to enter your home, yet lock down the sensitive parts of your
home such as locker etc.
In the future, smart villages and cities will inform relevant authorities
about emergencies and might even help avert impending catastrophe. Sen-
sors will monitor current situations and record changing conditions, and
any undesired changes in the environment will be given special attention.
To give an existing example of a smart network, some countries in the
world have modified their electricity grid to record voltages, current, fre-
quency and power consumption at various places. In this way, electricity
can be supplied as per demand. Some have even gone a step further by
letting appliances be completely switched on and off. If there’s a need to
completely switch off electricity in some region, say, in case of a short circuit,
a complete blackout is avoided.
Internet of Things 11
In the near future, parking lots and toll booths along highways will also
get smart and you’ll no longer have to stop at toll booths. As you travel along
the road, a camera will capture your car’s license plate and send a monthly
bill of your toll expenses to your home (So beware when lending your vehicle
to people).
Closer home also,
with time our surround-
ings will grow intelligent
enough to save electricity
and perform human tasks.
Besides monitoring and
maintaining the tempera-
ture in our houses and
cleaning it, devices will A solution to power Shortage / outage problem
also be able to monitor
our sleep and wake us up when it’s scientifically the right time to wake up.
So, in a couple of years when you turn on your TV, the blinds will auto-
matically close themselves to block sunlight and allow you to watch your
favourite match. Naturally, your next question must be: “How soon can we
expect this?” It depends on you really. You could be one of the creators of
this next technology revolution and help accelerate its development.
Microcontroller:
An integrated
processor
What’s common between a pocket
calculator, ISRO Mangalyaan,
Indian Air Force fighter planes
and navy warships, your cars,
bikes and your mobile phone?
14 Microcontroller: An integrated processor
T
hey’re all powered by the same technology that made the digital
revolution possible by making all devices portable and compact
in a cost effective manner – the microcontroller revolution. And
that technology is the microprocessor.
Microprocessors lie at the heart of every device that enables us to be our
virtual/digital selves. In addition, general and specialised microprocessors
are used to create a large variety of other products. It is due to the microcon-
troller that 3D printing has become available to the common man. They’re
undoubtedly the first choice for student projects and budding entrepreneurs
to develop models faster than previously imaginable.
A ‘microcontroller’ is yet another version of a processor that has enabled
the production of a wide variety of embedded devices such as the printer.
With increased capabilities
and increasing simplicity,
the use of microcontroller is
shifting from the experts to
the common man. This has
enabled the likes of the tink-
erer next door to go one step
ahead of the usual printer
and build a 3D printer just
as a hobby.
To put it simply, a micro-
A microcontroller controller is a “processsor
that concentrates on one
single task and allows other devices to connect for direct control of hardware
(such as a robot) or via peripheral devices”. In contrast, if hardware control
is via a computer at home, we need to connect the computer to the micro-
controller and then instruct the microcontroller to control the hardware.
The topic of microcontrollers is taught in the second or third year of
Engineering courses in India. But its increasing simplicity has enabled
even schools to teach the subject to students using microcontrollers for their
projects. This helps give the students a glimpse into how things around us
are built by tech developers.
They’re everywhere
The capabilities of electronic devices surrounding us have increased by leaps
and bounds. Mobile phones including smartphones, printers and tablets
Microcontroller: An integrated processor 15
Use cases
Microcontrollers are
used in places where
tasks performed are
predefined and rarely
complex. With these
Microcontrollers increasing interactivity devices, there always
will be some input that
has some definite expected output after processing. They’re used in video
games, computer mouse, washing machine, cameras, microwave, cars, bikes,
printers, landline telephone and mobile phones. Due to the high level of
specificity of applications, these devices have RAM, ROM and peripherals
integrated on the die of a single chip which helps reduce the size of the
processor and cost.
Microprocessors are used where tasks performed need a wider range of
capabilities such as scientific analysis, running servers, game and software
development, photo editing etc. These tasks need a high number of resources
such as RAM, ROM and processing power.
Let’s compare some of the features of both these devices:
• Speed of operation: The clock speed of the microprocessor is 100-1000
times faster than the microcontroller. Generally, microcontrollers operate
at a rate of 1 MHz to 50 MHz (excluding your smartphone) while most
microprocessors operate above 1 GHz.
• Processing abilities: Microprocessors have much higher processing
capabilities compared to microcontrollers as they perform complex
tasks involving a combination of multiple microcontroller instructions.
• Level of integration: A microprocessor is a chip with only processing
powers (contains only the processing unit commonly known as CPU
- central processing unit) and it doesn’t have other components like
Microcontroller: An integrated processor 17
RAM, ROM etc. integrated on the chip. All these components and other
peripherals need to be added externally to make a working system. A
microcontroller, on the other hand, has a CPU, RAM, ROM etc. all put
together on a single IC (integrated chip).
• Application: Microprocessors are used in desktop computers and laptop,
whereas microcontrollers are used in products where interfacing with
hardware is necessary such as in robots and MP3 players.
• Cost: So where does Arduino™ lie on the microcontroller landscape?
Arduino™ is a microcontroller-based board which makes possible
the easier development of hardware to develop quick prototypes. The
microcontrollers used are either 8-bit Atmel AVR series microcontrollers
or 32-bit Atmel ARM-based SMART series microcontrollers. They can be
programmed using a personal computer. Every Arduino™ board has digital
and analog pins, power pins, programming headers, serial communica-
tion, Pulse Width Modulation (PWM, explained more in chapter 6 section
Voltage Control using PWM) and Inter IC connect protocol (I2C) support.
Arduino™:
A simplified
open source
microcontroller
This chapter gives you an introduction
to the Arduino™ hardware and
software, and helps you pick the right
hardware for your application
Arduino™: A simplified open source microcontroller 21
S
ince its inception, the Arduino™ has been widely used to create
devices ranging from simple ones that help complete everyday tasks
to complicated projects such as remote control the flight of various
aircrafts in research. Students, hobbyists and professionals use it
widely as it simplifies the entire process of hardware design.
3. Motorised Snake
Everything in nature operates efficiently enough to serve as inspiration for
22 Arduino™: A simplified open source microcontroller
5. Quick Laces
Image credit: instructables.com
This is for the laziest
or busiest people who
don’t wish to waste
time tying laces.
Someone has even
automated tightening
shoe laces.
cylights.wordpress.com
possible using only
switches and LED
Image credit:
lights, there’s an
added advantage that
it could be turned off
automatically in case Bicycle turn indicator
you forget to turn it off.
What’s more, many Arduino™ board circuits could even be embedded
into your clothing!
Selecting the
one for your
creation…
With the wide range
of Arduino™ products
Selecting an Arduino™ board available in market,
Arduino™: A simplified open source microcontroller 25
which one should you select for your project? Let’s refer to the aforemen-
tioned list of devices in the table to pick one that fits our application. Many
things must be kept in mind when choosing a board, such as aesthetics
(especially for wearable technology). In the beginning stages of your project,
however, it’s always better to favour functionality over appearance, which
can be concentrated on later.
26 Arduino™: A simplified open source microcontroller
Robotics
Bluetooth
SD Card / Wi-Fi
Processor speed
The speeds mentioned in the table ‘List of Available Arduino™ Boards’
seem very low compared to that of a personal computer, but these devices
don’t carry out heavy computation. So don’t be tempted to get the 84 MHz
Arduino™ Due for its higher speed. You’ll observe that most of them per-
form tasks with equal speed.
In case you need more computing power, say, for statistical calculations
or video-related tasks, there are newer processors that can help. You’ll find
details of such boards in the chapter on Advanced Hardware. The speed
of processor also needs to be considered when a large number of devices
are connected to the microcontroller. For most applications, an 8 MHz
microcontroller will suffice.
28 Arduino™: A simplified open source microcontroller
Number of Pins
No. of Digital Inputs: No. of Analog Devices (such as sensors
Higher the number of sensors (with digital connected directly):
input) you wish to connect, higher the number Most sensors directly give analog values.
of pins that you’ll need. These can be converted to digital values by
Higher the number of output devices con- using external circuitry, but if your applica-
nected to a single microcontroller, higher tions demand analog input or you prefer using
the number of pins necessary. analog input, then remember that only a
(Shown in green and numbered starting from limited number of pins (around 4-12) accept
2 and going up to 13) analog input pins. Connecting any more
(Shown in light blue and numbered 0 and 1, if analog inputs will need more pins.
not used for serial data transmission) (Shown in blue and numbered from 0 to 5)
Analog out
Though most applications can use the digital form of analog signal
called PWM, some applications (such as audio) might need exact analog
output. In such case, the only available option is the Arduino™ Due,
which has an ARM processor with analog output via a 12-bit digital to
analog converter.
Arduino™: A simplified open source microcontroller 29
Though it might seems like you have very few pins when you start
building applications, you’ll soon find that most of your pins are still free!
UPGRADING FROM
Uno Leonardo Due Mega Ethernet Mega 2560 UPGRADING
ADK TO
Arduino™
VARIANT
CONSIDERATION WHEN UPGRADING
- Compat- Compatible Compat- Compat- Compatible Uno
ible ible ible
Compat- - Compatible Compat- Compat- Compatible Leonardo
ible ible ible
Analog Analog - If Analog Analog If Analog Due
out, native out, native out and out, native out and
USB, extra USB, native USB, extra native USB
pins if not extra pins USB are pins if are not used
used if not used not used. not used
Extra Extra Compatible - Extra USB host Mega ADK
pins and pins and pins and feature if
USB host USB host USB host not used
feature, if feature if feature if
not used not used not used
If Ethernet If if Ethernet Compat- - If Ethernet Ethernet
port is Ethernet port is not ible port is not
not used port is used used
not used
Extra pins Extra pins Compatible Compat- Extra pins, - Mega 2560
if not used if not used ible if not used
Software
The Arduino™ IDE (Integrated Development Environment) is software
that’s used to write the code which is run on the microcontroller of the
Arduino™ board. Here’s how to install it on popular platforms:
Windows
1. Download the Arduino™ IDE installation file (Arduino-1.0.6-windows.
exe) from http://dgit.in/ardsoft.
a. For the Arduino™ Yún and Arduino™ Due boards, you’ll need the
Arduino 1.5.8 version available at http://Arduino.cc/en/Main/Software.
2. Open the downloaded file and install it.
Linux
1. Ubuntu/Debian users can install the IDE by opening the terminal and
giving the following command:
• sudo apt-get install Arduino
2. Others can download the corresponding IDE from http://dgit.in/ardsoft
depending on whether you’re using the 64 or 32 bit version of the OS.
3. Extract the downloaded archive using the following command:
• tar zxvf <filename>.tgz
4. Open the extracted folder in the terminal.
Arduino™: A simplified open source microcontroller 33
Sketches
A piece of code or program written in
the Arduino™ IDE is called a ‘Sketch’.
The name has been borrowed from
Processing’s IDE ‒ the software that
inspired the Arduino™ IDE’s GUI.
Also, since Arduino™ was originally Arduino™ Integrated Development
aimed at designers, the name Sketch Environment
remained a natural choice among
the developers.
The Arduino™ development environment is divided into the following
parts, illustrated in the picture (These names are given for our convenience):
1. Menu bar: Contains the necessary functions and options to select the
board you’re using and the port the board is connected to.
2. Quick shortcuts: Shortcuts (see table) are available for frequently used
functions such as verifying the sketch and uploading it. Before using these
options, ensure that you’ve selected the correct board from the ‘Tools’ menu.
3. Sketch Name: When a single project has many files, you can see each
of them in tabs with the corresponding name on this bar.
4. Sketch Editor: All the code that’s flashed (written to the microcontroller’s
EEPROM) is written in this part of the IDE.
34 Arduino™: A simplified open source microcontroller
Libraries
Libraries are files written in C or C++ (.c, .cpp) to provide extra function-
ality to your sketches. They lie at the crux of Arduino™ code and are the
Standard Libraries
Reads and writes to “permanent” storage. EEPROM
Connects to the internet using the Arduino™ Ethernet shield. Ethernet
Communicates with applications on the computer using a standard serial Firmata
protocol.
Connects to a GSM/GRPS network with the GSM shield. GSM
Controls liquid crystal displays (LCDs). LiquidCrystal
Reads and writes to SD cards. SD
Controls servo motors. Servo
Communicates with devices using the Serial Peripheral Interface (SPI) Bus.
SPI
Serial communication on any digital pins. Software
Serial
Controls stepper motors. Stepper
Draws text images and shapes on the Arduino™ TFT screen. TFT
Connects to the internet using the Arduino™ shield. Wi-Fi
Two Wire Interface (TWI/I2C) that sends and receives data over a network Wire.
of devices or sensors.
36 Arduino™: A simplified open source microcontroller
Libraries contributed by
users
The contributed libraries aren’t
available in the standard Arduino™
IDE installations and can be Adding user contributed libraries
obtained from http://dgit.in/ardlibrary.
Installing the user contributed
library:
1. Download the library.
2. In the menu bar, go to Sketch
> Import Library > Add
Library (as shown in the Library list showing newly added ‘Time’ library
figure).
3. Select the downloaded .zip file and click on ‘Open’ to add the new library.
4. The new library will be added and can be seen at the end of the library
list (Sketch > Import Library).
Arduino™ community
The Arduino™ community is an active group of Arduino™ enthusiasts and
developers, both - beginners and experts. The Arduino™ forum at http://
dgit.in/ardforum acts as a meeting place for the entire Arduino™ community.
The forum is divided into sub-forums such as Using Arduino™, Topics,
Development and Community for easy access.
From enthusiasts who create their own libraries and make them avail-
able to other users to third-party developers who create specialised hard-
38 Arduino™: A simplified open source microcontroller
Sensing
Capacitive
Turns two or more pins into capacitive sensors.
Sensing
Reads noisy digital inputs (e.g. from buttons). Debounce
Timing
A library for keeping track of the current date and time in software. DateTime
Helps you time actions at regular intervals. Metro
Uses the timer 2 interrupt to trigger an action every N milliseconds. MsTimer2
In conclusion
Thus, we can summarise that the Arduino™ is a microcontroller-based
platform backed by a large community of developers that has simplified the
way electronic hardware is programmed. We looked at different boards as
well as parameters to be considered when choosing a board. We also now
know about the difference between hardware and software programming
and how Arduino™ has simplified hardware programing by developing
libraries. Here’s hoping that all this information has piqued your interest
enough to want to develop your own libraries! Now let’s look at some add-on
hardware known better as ‘shields’.
40
Chapter #05
J
ust as we can add on a graphics card using the PCI-e port of our com-
puter, we can add a ‘shield’ using the port pins on the Arduino™ board.
While graphics cards enhance the gaming experience or video editing
capabilities of our computer, Arduino™ shields add extra functionality
to the Arduino™ board.
Arduino™ acts as a platform for the development of many kinds of
applications. The creation of such applications is supported by the addi-
tion of extra hardware such as sensors and motors connected to the pins
on the board.
What’s a Shield?
A ‘shield’ is basically a printed
circuit board (PCB) with some
integrated circuits (ICs) and other
hardware connected in a manner Why Shield?
that allows it to be directly placed
on top of an Arduino™ board. Moreover, a shield also simplifies the devel-
opment process by providing libraries for easy programming.
Shields available
Many different types of shield are available for various purposes. Given
below is a list of available shields and the purpose they’re used for.
Sketching
the code
To perform a task, you need to instruct
the device what to do. But, Arduino™
(hardware) programming is slightly
different. Let’s see how to do it
Sketching the code 47
P
rogramming in this context is about instructing an Arduino™
about the manner in which it should perform a task. Just as
humans need to be trained to be able to carry out an activity, so
does the microcontroller. However, the mode of instruction is an
altogether different language, a coded form of English.
Without the correct program loaded, an Arduino™ board is like a fruit
that’s not ripe, i.e. It’s not ready to serve its purpose yet. An uploaded pro-
gram will bring your Arduino™ board to life.
Programs are chunks of coded instructions that tell the microcontroller
on the Arduino™ board what task to perform next. Using a series of these
coded instructions, the microcontroller performs mathematical operations
to make a calculation or take a decision. While programming seems like
a difficult task to many people, nothing could be further from the truth.
Programming is only slightly challenging. Look at it like thinking from
the point of view of another person. In this case, thinking from the point of
view of the microcontroller. To write a program, all we need to do is:
Think about the task we need to perform.
Develop a logic and set of mathematical operations that can help perform
the task. (Not as hard as it sounds. Using a flowchart to develop the logic
can help a lot and is a recommended step for beginners. (Check http://
dgit.in/learnflowchart for more details on designing a flowchart.)
Check if the microcontroller can directly use the logic and
maths operations.
In case the microcontroller can’t carry out the operation directly, try
using alternative ways.
Tweak the code.
Programming the
hardware
If you have prior experience
with software programming,
you’ll notice there are minor
differences between software
programming and program-
ming a hardware device.
Hardware programming is
more like writing drivers for
your computer hardware. What is programming?
48 Sketching the code
Verifying
This is the process of checking the code written for any errors in syntax.
50 Sketching the code
Uploading
Arduino™ programs can be
uploaded to the board by using the
Upload shortcut in the Quick
‘Done Uploading’ window denoting that
Shortcuts menu. uploading was successful.
Before uploading any program,
the IDE verifies the program, compiles it to convert it into a machine code
called ‘hex’ code and then writes this hex code to the flash memory of the
microcontroller. Hex code is binary code containing ‘1’s and ‘0’s and is the
only language that microcontrollers and processors understand.
On successful completion of uploading the program, the Arduino™
IDE will show a success message in the Message window as shown in the
image here.
Serial Monitor
After uploading the sketch on the
Arduino™ board, you can check the
output using the Serial Monitor with
symbol if you’ve used the ‘Serial.
write()’ function in your code. Setting ‘Newline’ in Serial Monitor
LED blink
Every Arduino™ board has an LED connected to Pin 13. We’ll use this LED
to write the first code. The best thing about this piece of code is that it doesn’t
need any extra hardware to be attached to the Arduino™ board. Since a
display is optional in the electronics world, the LED is commonly used as
a debugging tool to check if things are working as you want them to work.
There’s no direct way to keep an LED blinking. To achieve this, we need
to trigger the following algorithm:
1. Turn on the LED
2. Wait for some time
3. Then turn it off
4. Wait for some time
5. Again repeat Step 1
Connect the Arduino™ via USB cable and enter some data in the
serial monitor.
For those who need the data in Binary, Hex, Decimal or Octal format,
add an extra parameter that specifies
the requirement.
is necessary measurement.
To use an accelerometer, we
first need to fix the zero point of
the accelerometer.
Steps to set the zero point for
your accelerometer:
1. Set the variable zero_point in
the below program to zero i.e.
zero point = 0;
2. Hold the board straight (par-
allel to the ground) and watch
the serial monitor.
3. When the xAcc and yAcc Accelerometer ADXL335 connected to the
values show same value, that Arduino™ board. The Vcc voltage for the accel-
erometer ADXL335 in above figure is 3.3 V
value is the zero point
4. Change the value of variable
zero_point in the program disregarding the sign of the value.
a. xacc and yacc will show negative value (-290 in our case). Disregard
the negative sign and set zero point = 290 in the sketch.
An accelerometer is a very
sensitive device and is used when
fast measurements are necessary,
but the device is also sensitive
to external disturbances that
change its value and therefore
needs to be used with care.
Using a Gyroscope
Programming a Gyroscope isn’t
as simple as programming the
Accelerometer. It uses the I2C Connect the GYROSCOPE ITG-
(Inter IC Connect) communica- 3200 to the Arduino™
tion protocol via the SDA (data
line) and SCL (clock line). You’ll need to understand the data sheet of Gyro-
scope to understand the code. We recommend asking one of your friends
who’s an electronics expert to help you understand the code.
You can find a copy of the code at http://dgit.in/ardgyrocode and related
explaination at http://dgit.in/ardgyroexp.
Sketching the code 59
Using Shields
To use a Shield with your Arduino™ boards, you need to place it on top of the
Arduino™ board. You can also stack up multiple shields on top of each other
Serial.println (“Scanning
available networks...”);
listNetworks (); List all available Wi-Fi networks by calling
the ‘listNetworks ()’ function defined below
Serial.print (“Enter name
of network: “);
readSerial (ssid); Call a function named ‘readSerial ()’ to
read SSID (name) of network entered
by user and store in variable ‘ssid’
Serial.print (“Enter password: “);
readSerial (pass); Call function ‘readSerial ()’ to read password
entered by user and store in variable ‘pass’
Serial.println (“Attempting
to connect “);
status = WiFi.begin (ssid, pass); Connect to Wi-Fi network with name
‘ssid’ and password ‘pass’
if (status ! = WL_CONNECTED) { Check if you’re connected to the
Wi-Fi network connection
Serial.println (“Couldn’t
get a wifi connection”);
while(true); Stop further execution since you’re not
} connected to any Wi-Fi network
else {
Serial.println (“Con- Display success message
nected to network”);
}
}
void loop () {
// do nothing
}
FUNCTION TO LIST AVAILABLE NETWORKS
void listNetworks () { Function to list all available Wi-Fi networks
Serial.println (“Available Networks: “);
byte numSsid = WiFi.scanNetworks (); Scan for available networks and store
count in variable ‘numSsid’
Serial.print (“number of
available networks:”);
Serial.println (numSsid);
for (int thisNet = 0; For every network found, print following data
thisNet<numSsid; thisNet++) {
Serial.print (thisNet); Print count of network
Serial.print (“) “);
Serial.print (WiFi.SSID (thisNet)); Print SSID (name) of the Wi-Fi network.
Sketching the code 61
Since we’re only connecting to the Wi-Fi network and not doing any
further processing, we’ll leave the loop() function empty and stop the pro-
gram after trying to connect to the Wi-Fi network.
Receive SMS
The following code snippet allow you to send SMS using the Arduino™
GSM shield. It can be very useful in developing applications that allow you
to control hardware through SMS. Further, the data in the message can be
tested using conditions to perform specific actions such as switching ON
and OFF the AC at home.
You can find a copy of the code http://dgit.in/ardrecsmscode at and related
explaination at http://dgit.in/ardrecsmsexp.
Send an SMS
Though we can receive SMS using the Arduino™ shield and control many
Sketching the code 65
aspects of life, there may arise a need to send an SMS via the Arduino™
shield to your mobile phone to monitor many conditions and take actions
depending on that condition such as the thirsty plant in need of water that
we saw in Chapter 1. Instead of email, SMS could have been a medium for
communication. Critical application areas such as healthcare are better
suited to use SMS in case of emergencies even when Internet might be
available, since there’s a higher possibility of an SMS being sent.
Let’s look at the code to send an SMS using an Arduino™ device.
You can find a copy of the code http://dgit.in/ardsendsmscode at and related
explaination at http://dgit.in/ardsendsmsexp.
Note:
When using a shield, proper power supply should be connected to supply the
required power. Though the Arduino™ board can be powered via the USB port of
your computer, the shields you’re using or the components connected to them re-
quire much more power for smooth operation. For instance: The GSM shield may
need up to 2 A of current for proper operation, but the USB port of a computer can
provide a maximum of 500mA of current via the USB 2.0 port and 900mA current
via the newer USB 3.0 port.
We’ll divide the Arduino™ code into the following broad categories,
based on the reason for its use, namely:
Input / Output via pins
• Digital Input / Output
• Analog Input / Output
Delay
Serial Communication
Input / Output
Note: Before using a pin, it’s necessary to set the function of that pin.
Neglecting this can lead to unwanted behaviour from the code. By default,
the pins on the ATMega based Arduino™ are configured to be used as
input pins.
The function that the pin is used for is set using the ‘pinMode ()’ function
in the ‘setup()’ function of the code.
The pins on the Arduino™ can be used as either input pins or output
pins and are configured using the following syntax:
Digital Write
To write data using the digital write pins, use the following syntax:
Code:
• int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin 13
as output
}
void loop() {
digitalWrite(ledPin, HIGH); // write logic HIGH to pin 13,
making output voltage +5 V
}
Digital Read
To read data using the digital pins, use the following syntax.
• digitalRead (pin)
This reads the value from the specified digital pin, either HIGH or LOW.
Code:
• int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup() {
pinMode(inPin, INPUT); // sets the digital pin 7 as
input
}
void loop() {
val = digitalRead(inPin); // read the value at input pin
and store in variable val
}
Analog Pins
Analog pins on the Arduino™ only read analog data. They have an Analog-
to-Digital converter connected to them, which reads the voltage at the pin
and converts it to digital form. Since it’s a 10-bit Digital-to-Analog converter,
the resulting range of ‘analog read’ function is 0 to 1023.
The syntax to use analog read is:
• analogRead(pin);
68 Sketching the code
Code:
• void setup(){
• pinMode(A0, INPUT);
• }
• void loop(){
• analogRead(A0);
• }
Code:
• int led = 10;
• void setup () { }
• void loop (){
• analogWrite (led, 127); // Generates a PWM wave of 50%
duty cycle of average voltage of 2.5 V.
• delay (5000);
• analogWrite (led, 64); // Generates a PWM wave of 25%
duty cycle of average voltage of 1.25 V.
• delay (5000);
• }
Delay
The ‘delay’ function causes the execution of the Arduino™ board to pause
for the specified amount of time.
• delay(1000); // wait for 1 second
The parameter passed to the delay function is the time that it should
Sketching the code 69
Serial Communication
The Arduino™ ecosystem allows serial communication using the serial
class. The library for serial communication is built into the default
Android installation.
• Serial.begin ()
Before data is sent over the serial communication port, the serial port
needs to be initialised. The syntax for initialisation is:
• Serial.begin (9600)
This initialises the serial port at a baud rate of 9600 bits per second. The
Digital Pins 0 (Receive - RX) and 1 (Transmit - TX) are used for serial com-
munication. These pins can’t be used for any other other task when using
them for serial communication. 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).
Serial.print ()
After beginning the serial communication, data can be transmitted using
the print command, whose syntax is:
• Serial.print (data);
where ‘data’ is the data to be transmitted over Pin 1 of the Arduino™
board. This command sends the data to the Arduino™ Serial Monitor.
To start on a new line after printing the data, use the following command
Serial.println (data);
Code:
• void setup () {
• Serial.begin (9600);
• }
• void loop () {
• Serial.println (“1) This line will appear on top”);
• Serial.print (“2) This line will appear below line no
1”)
• }
Serial.available
When receiving data using serial communication, you need to verify that
70 Sketching the code
Serial.read
This command reads the incoming serial data one byte at a time. It’s used
along with serial.available to ensure that the data has been received before
it’s read and stored. The syntax of the function is:
• storage _ var = Serial.read ();
Code:
• int incomingByte = 0; // variable for storing incoming
serial data byte
• void setup() {
Serial.begin(9600); // opens serial port, set-
ting baud rate to 9600 bps
}
void loop() {
if (Serial.available() > 0) { // checks if data
has been received
int incomingByte = Serial.read(); // reads
the incoming byte
}
}
recheck your code for mistakes (errors apart from syntax errors – i.e. typos)
that may have crept in while you were programming.
Here are some of the programming blunders that can cause errors:
1. Incorrect syntax
This is one syntax error that cannot be detected by the ‘Verify’ step.
Let’s say you want to use the comparison operator == (i.e. two equal
signs) to compare value like this:
• if (i == 4)
and instead you write:
• if (i = 4)
Using the = (single equal sign) assigns a value of 4 to variable i and the
statement is evaluated to ‘true’ causing huge unnoticeable errors.
2. Overflow errors
Overflow errors are errors caused when the limit of variables are exceeded
E.g. Let’s say you write a code with variable i declared as an integer.
The range of integer for Arduino™ UNO board with 16-bit microcon-
troller is -32,768 to 32,767.
So if you exceed 32767 or go below -32,768, overflow occurs and the
microcontroller can’t count further and starts using ‘false’ value.
These are some invisible blunders that are neither easily noticed nor
are they highlighted by the Verify tool.
To conclude...
In this chapter, we saw how to install Arduino™ software, make the
Arduino™ environment ready to upload sketches, and verify and upload
sketches. We then looked at a few programs to get the LED to blink, and
for use with the display, sensors and various shields. We then looked at the
syntax used in the Arduino™ environment that’s an add-on to the general C
language to achieve hardware control. And if your sketch doesn’t respond
as you intended, you can refer to the final part of this chapter that points
you to some possible errors that may have sneaked in.
We wish you the best of luck in putting the pieces of code in the
right place.
72
Chapter #07
Applications
of Arduino™
In this chapter, we’ll look at components
that are a part of interesting electronic
projects and discuss a few project ideas
W
hat you’re seeing in the opening image is a visual repre-
sentation of the real world by the sensors that help drive
the Google car autonomously. The driver can enjoy the
journey like his co-passengers and take over when he
wants to. The sensors acquire data from the real world and pass it on to
the computer that calculates the different possibilities and takes decision
Applications of Arduino™ 73
accordingly to control the car. Sensors and other components thus help
achieve many tasks. This chapter discusses these parts and also details
some projects.
Sensors
There are many different types of sensors that can be classified according
to their area of application.
For creating a project, you need sensors to sense the environment and
actuators to perform the required action.
Project ideas
In this section, we’ll look at some possible projects using the Arduino™ platform.
How to implement:
1. Connect the Arduino™
board to measure the
resistance of soil.
2. Measure the voltage Relay circuit for using motor
Applications of Arduino™ 75
at the required moisture level and set this voltage in the Arduino™
sketch. Measure the voltage between analog pin 0 and ground of the
Arduino™ board in the above circuit to calibrate the system to the
required moisture level.
3. Then use the Digital Pin 13 to turn on the motor if the soil is dry.
To switch a motor ON or OFF, we need to use a relay. However, the relay
itself needs very high current. It, therefore, needs to be connected using the
circuit described with the given Transistor 2N2222.
Check more details about the project at http://dgit.in/garduinO
How to implement:
You’ll need to use the
Motor shield along with the
Arduino™ board to drive
the motors connected to the Wireless toy car
toy car. (The code for this is
explained in Chapter 6.)
To steer the 4-wheeled vehicle, you’ll use the driving mechanism called
‘differential’ drive. It uses the following motor rotation directions to steer
the toy car:
How to implement:
Use the Ultrasonic sensor to read the distance directly in front of the robot.
The Ultrasonic sensor sends an ultrasonic wave (sound inaudible to
humans).This ultrasonic wave reflects from obstacles directly in front of
the sensor. The program on the Arduino™ board measures the time of
Applications of Arduino™ 77
How to implement:
Use the LilyPad Arduino™ to detect when the push button switch is
pressed by the user.
If the user presses the switch, change the state of LED connected to
that side:
• Turn OFF the LED, if LED are already ON.
• Turn ON the LED, if they’re already OFF.
• You can use ‘digitalWrite’ function to achieve this functionality.
Place the LilyPad Arduino™ on your jacket along with the batteries.
Wire the LEFT turn LED together and the RIGHT turn LED together
as shown in the picture.
Connect the batteries and test the circuit.
The FTDI connector will be required to program the LilyPad Arduino™.
78 Applications of Arduino™
Quadcopter
The movie ‘3 Idiots’ features a flying machine with four motors that allow
it to be flown around in any direction as well as hover at a place like a
helicopter. The device in this project, however, is much more flexible and
Applications of Arduino™ 79
To conclude...
This chapter kicked off with the basics of sensors and a brief explanation
of how the real world interacts with computers via sensors and actuators
to carry out tasks. Then, you learnt of the different types of sensors around
and their areas of applications with a few examples of each. Now that
you’re aware of the types of practicable Arduino™ projects – right from an
automatic garden watering system (inspiration from the first chapter) to an
autonomous wheeled robot and persistence of vision wand, moving all the
way up to research unmanned aerial vehicles, namely, quadcopters – you
can get started with your first project. There are many interesting projects
on the internet to fire up the creative genius in you.
80
Chapter #08
Advanced
Hardware
With improvement in computer
processing capabilities, we’re able
to achieve more human capable
tasks from our hardware devices
than ever before. Thus, the necessity
to look at advanced hardware
Advanced Hardware 81
T
he higher processing capabilities of devices and newer algorithms
have brought about a radical change in the list of possibilities in
the technology world. Catching up with this trend are program-
ming related hardware. Combining hardware programming with
software programming will enable making unimaginable tasks possible.
Any solution?
Definitely. This is where the role of advanced hardware comes into play.
These advanced hardware devices have far greater processing capabilities
than existing ones. But before we talk about that, let’s see if there are any
solutions to the problem of navigation for the blind.
There are algorithms that can detect how far an object is from you, by
using images from a camera.
Since you’re using images, you can separately detect cars and other
objects, to warn users about any possible vehicle directly in front, so
that he can take necessary precautions.
It’s also possible to detect road signals to inform the person when he
should cross the road.
Using images, the system can detect the text on signboards, for instance,
by running images through an optical character recognition system. So
apart from being just
a navigation system,
the system also acts
as an assistant and
artificial eye.
Though this solution
is great, it definitely has
limitations:
It can better detect
objects in front than
at the side. So the
user needs to move
to detect objects on Advanced navigation for the blind
either side.
Fast moving vehicles are still a problem in areas without signals.
Let’s bring the Internet of Things capability of these advanced devices
into the picture.
Imagine a completely connected world that might exist in the future.
All vehicles in this hypothetical future have GPS showing their
current position.
The device that the blind person possesses also has a GPS system that
detects his current location.
The GPS device helps the blind person navigate with appropriate
guiding directions.
Advanced Hardware 83
The route being travelled by the vehicle and the person are pre-entered.
Now, when the blind person approaches a crossing, the system will
alert both, the car and the blind person. In this way, both will take extra
precautions while the blind person crosses the road.
This system could also help when small children with GPS devices
attached cross the road by informing the drivers of kids in the vicinity.
The boards
Three such boards with higher capabilities are currently available – two
are manufactured by Arduino™ along with partners and one is manufac-
tured by Intel.
84 Advanced Hardware
Arduino™ boards
• Arduino™ Yún
• Arduino™ Tre
Intel board
• Intel Galileo (Arduino™ compatible board)
Arduino™ Yún
The Arduino™ Yún board com-
bines the power of Atmel AtMega
series ATmega32u4 microcontroller
and the Atheros AR9331 chip. The
Atheros processor supports a Linux
distribution based on OpenWrt
named ‘OpenWrt-Yun’. Arduino™ Yún board
Advanced Hardware 85
Hardware specs
The specifications for the Linux part of hardware:
Processor: Atheros AR9331
Architecture MIPS @400MHz
Ethernet IEEE 802.3 10/100Mbit/s
Wi-Fi IEEE 802.11b/g/n
USB Type-A 2.0 Host
Card Reader Micro-SD only
RAM 64 MB DDR2 memory
Flash Memory 16 MB
The Yún combines the power of Linux with the user friendliness of the
Arduino™ platform. It can communicate with the Linux distribution on
board, offering a powerful networked computer. Linux shell scripts and
other programming languages such as Python scripts can also be used.
It also allows the use of Linux commands that allow data transfer to and
from a server, using protocols like DICT, FILE, FTP, FTPS, GOPHER, HTTP,
HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP,
SFTP, SMTP, SMTPS, TELNET and TFTP via the ‘cURL’ command.
The ATmega32u4 on the Yún has built-in USB communication. This
eliminates the need for a secondary processor. Thus, in addition to being a
virtual serial/COM port, the Arduino™ Yún board can appear as a periph-
eral (such as a mouse and keyboard) to a connected computer.
The Bridge
The Arduino™ Yún com-
bines the power of Linux
running on the Atheros
AR9331 processor and the
Arduino™ platform directly
supported by the ATMega
32u4 microcontroller. This
makes it necessary to allow
communication between the Arduino™ bridge and interfacing of ports
86 Advanced Hardware
cessor causing the reboot of the Linux system. This will lead to loss of
data in the RAM of the Linux system.
Hardware specs
Apart from the specifications of the on-board Atmel ATMega 32u4, the
following additions have been made open:
As given in the list of specs, the Tre has pins with 3.3 V logic voltage
level, making it necessary to convert the 5 V logic voltage to 3 V as needed
in most applications.
88 Advanced Hardware
The Arduino™ Tre runs the Linux Debian operating system on the
Sitara processor. It has a new revamped Integrated Development Environ-
ment developed specifically for the Tre. The IDE comes pre-installed in the
Linux environment and can be accessed via the web browser. When the
Tre is connected to your computer via USB, it sets up a virtual network
interface and can be accessed on the IP address 192.168.7.2 on the developer
edition. An initial screenshot of the new UI is shown in the image, however,
changes are possible.
As in the Arudino Yún, the Tre also uses the bridge for communication
between Linux processor and ATMega 32u4 processor. Changes have been
made to the bridge to allow flexible usage and for bug fixes.
Though there aren’t many details available on the Tre from Arduino™ as
of now, we expect it to be used by developers for the following applications:
Robotics
Image processing of live video feed to detect objects (as in the example
at the beginning of this chapter of a navigation system for the blind).
Statistical computation of data from sensors and other devices
It could also find its way into applications like Artificial Intelligence
Intel Galileo
Intel Galileo combines the compute power of the Intel Quark processor with
the simplicity of the Arduino™ platform. The Arduino™ platform enables
Advanced Hardware 89
anyone with the knowledge of C/C++ to program hardware. The Galileo plat-
form blends the ease of Arduino™’s hardware manipulation with the power
of a fully operational Linux operating system. Most sketches (Arduino™
programs) written for Arduino™ boards can be ported over to the Galileo
with little or no modification. All
popular Arduino™ libraries such
as SD, Ethernet, Wi-Fi, EEPROM,
SPI and Wire are available along
with access to the Linux side of the
board with calls via the ‘system()’
function.
The Galileo board has the
advantage of being able to run
Linux environment along with
the Arduino™ code, combining Intel Galileo Board
the best of both worlds. The Linux
OS can be loaded to an SD card, and Galileo can be set to boot from the Linux
image. Using the Linux image, the following features become available:
Wi-Fi drivers: The Galileo supports Intel Wi-Fi cards via drivers
included in the Linux image. There are many mini-PCIe Wi-Fi cards.
Python: There are Python scripts readily available that can check for
unread email or perform tasks. Custom Python scripts can also be easily
created to enhance functionality and truly make your device an Internet
of Things device.
openCV: OpenCV or Open Source Computer Vision is a library. Using
a webcam connected to the USB port of the Galileo board, a live feed
from the camera can be captured to perform some tasks such as object
detection or recognition.
SSH: Secure Shell (SSH) is a command line tool/protocol to securely
access a remote computer. This can enable applications such as remote
controlling a Galileo that’s monitoring a home or simply communicating
with the Galileo board without the serial communication port.
Node.js: Node.js is a library dedicated to building server-side applica-
tions in Javascript. Node.js is meant to run on an HTTP server and its
applications are event driven. Most suited for web projects.
ALSA: Advanced Linux Sound Architecture (ALSA) enables the Galileo
board to play sound.
V4L2: Video4Linux2 is a video record and play Linux utility.
90 Advanced Hardware
Hardware specs
Processor:
Intel® Quark SOC X1000 application processor
• 16 Kbytes L1 cache
• 512 Kbytes of on-die embedded SRAM
• Single thread, single core, constant speed
• 400 MHz clock speed
256 MB DRAM
To conclude…
In this chapter, we looked at some yet to be released hardware (Arduino™
Tre) as well as existing platforms such as Arduino™ Yún and Intel Galileo
that add the extra punch of processing power for scientific applications and
applications that run advanced algorithms like Image Processing. Inspite of
being advanced hardware, they still inherit the simplicity of the Arduino™
platform and allow communication between the computing chip running
Linux and microcontroller running its own code. Hope you use them to
make the impossible possible.
91
ChapterPrimer
#09 to Electronics
Primer to
Electronics
There are few things that need to
be kept in mind when creating
electronic devices. Connecting
things correctly doesn’t mean they’ll
behave as intended on the first go.
92 Primer to Electronics
W
hen working on an electronics project, various electrical
parameters such as voltage and current need to be
considered for proper implementation and functioning
of your project. This chapter touches upon the neces-
sary parameters that a beginner should necessarily be aware of. We’ll
then look at some ways to troubleshoot your project and finally learn
how to use the power supply of your desktop computer to power your
Arduino™ hardware.
Parameters of importance
Voltage: Voltage is actually a dif-
ference in electrical energy (called Power is a parameter that’s
‘potential’) between two points. So usually ignored by beginners in
when we say “connect the device to electronic design. However, it
a voltage of 5V (5 volts)”, you can needs to be taken into considera-
connect the device between 5V and tion when connecting devices.
GROUND (0V) which is 5-0=5V, or Connecting high power devices
you can connect between 10V and directly can damage circuits and
5V giving 10-5=5V. devices they’re connected to.
Current: When voltage that’s more So check for power requirement
than zero is applied, electrons carry when you connect your next
energy, and the flow of these elec- device. Devices such as motors
trons is called ‘current’. This is need lot of power for their opera-
measured in Amperes (A). tion and hence should never be
Power (denoted by P): The power connected directly in the circuit.
a device uses, generally measured They need special chips called
in watts, is the product of voltage motor drivers, which can supply
and current. the required amount of power.
The USB port 3.0 of our computers
provide 5V voltage and current of 1A.
So the maximum power it can supply is P=V x I = 5 x 1= 5W. So when we
charge a mobile phone or an MP3 player via our computers, 5 watts is the
maximum rate of charging.
Terminology
GROUND: It’s assumed that the GROUND is always 0V. When used in
a circuit, it’s denoted by the symbol . Remember ‘0V’ and ‘GROUND’
are both used interchangeably.
Primer to Electronics 93
Physical components
in an electronic circuit
Resistor
As the name suggests, ‘resis-
tors’, well, resist the flow of
current and are used to avoid
damage due to high current. Reading a colour coded resistor
It’s denoted by the symbol Ω
and is measured in a unit called ‘Ohm’.
Colour coding is used to denote the value of the resistor. The table here
shows colour coding, using which the resistor values are read.
Reading resistor values is important. Let’s see how to do it:
1. Hold the resistor with the SILVER or GOLD coloured band towards the
right as shown in the table.
2. Use the table at http://dgit.in/resistorcode to find the actual value of
the resistor.
3. The first two colour bands on the left denote the value of the resistor.
4. The third band denotes the multiplier.
5. The last band denotes the tolerance.
Tolerance is the variation in the value of resistance that can be expected
from the resistor you have. Lower tolerance signifies lower variation in
resistance and thus proper functioning of the circuit.
In our given figure, the value of resistor is
1st band 2nd band Multiplier (3rd band) Tolerance (4th band)
2 (red) 7 (violet) ×103 (green) ±5%
IC (Integrated Circuit)
When using an ‘integrated circuit’, all connections are made using pin
numbers of the IC.
Numbering of IC pins
The most important thing to know is where the 1st pin is located on any IC.
2. The first pin from the top on the left of the notch is
the first pin of the IC and the pins are counted as
shown in the figure.
Multimeter
A ‘multimeter’ is a device that measures multiple elec-
trical parameters such as voltage, current and resistance.
A digital multimeter (as shown in the image) displays
the required value by selecting the required quantity
using the dial below the display.
Continuity tester
After creating an electronic circuit on a breadboard or
a printed circuit board (PCB), things may not work as
expected. Though everything may seem fine, this hap- A digital multimeter
pens if there are loose or faulty connections between
two points. The continuity tester is used to check if there are any such
problematic connections.
Please note that the continuity tester indicates whether a short circuit
exists between any two points and isn’t effective for checking whether there’s
resistance between two points. You can even
make a continuity tester using an LED, a battery,
a resistor and some wire to connect them. If you
have access to a multimeter, there’s an in-built con-
tinuity tester. It can be used by turning the knob
to the symbol shown in the image. In the presence Continuity tester symbol on a
of a continuity, the device makes a buzzing sound. digital multimeter
96 Primer to Electronics
Troubleshooting your
hardware
Check if the power supply is ON and
connected properly.
Check if all pins have been
connected properly.
Check for any hot components. If
there are any, chances are that the ATX power connector
component is damaged.
If the PCB gets hot, then you have a
faulty PCB with a short circuit. You’ll need to get a newer one.
Use a continuity tester to check for faulty connection.