0% found this document useful (0 votes)
7 views36 pages

Arduino Ultrasonic Distance Meter

This document discusses the construction of a distance measuring device using an Arduino board and ultrasonic sensors. It outlines the background of distance measurement techniques, the aim and objectives of the project, and the components used in the construction. The project aims to create a simple, accurate device capable of measuring distances from 2cm to 400cm.

Uploaded by

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

Arduino Ultrasonic Distance Meter

This document discusses the construction of a distance measuring device using an Arduino board and ultrasonic sensors. It outlines the background of distance measurement techniques, the aim and objectives of the project, and the components used in the construction. The project aims to create a simple, accurate device capable of measuring distances from 2cm to 400cm.

Uploaded by

Akachi Okoro
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CHAPTER ONE

1.0 INTRODUCTION

1.1 BACKGROUND OF STUDY

Distance measurement, length measurement, or range measurement (ranging) re


fers to the many ways in which length, distance, or range can be measured. The
most used approaches are the rulers, followed by transit-time methods and the i
nterferometer methods based upon the speed of light.

As technology kept advancing, more sophisticated and reliable way of


measuring distance kept emerging. One of the modern ways is using the
ultrasonic sensors. The Ultrasonic sensors are basically transducers that
generate or sense ultrasound energy. They can be divided into three broad
categories: transmitters, receivers and transceivers. Transmitters convert
electrical signals into ultrasound, receivers convert ultrasound into electrical
signals, and transceivers can both transmit and receive ultrasound. The
ultrasonic sensor find this special application in time measurement based on the
principle of transient time measurement. The basic idea behind a transit-time
measurement of length is to send a signal from one end of the length to be
measured to the other, and back again. The time for the round trip is the transit
time Δt, and the length ℓ is then 2ℓ = Δt*"v",with v the speed of propagation of
the signal, assuming that is the same in both directions.

Transit-time measurement underlies most radio navigation systems for boats


and aircraft, for example, radar and the nearly obsolete Long Range Aid to
Navigation LORAN-C. For example, in one radar system, pulses of
electromagnetic radiation are sent out by the vehicle (interrogating pulses) and
trigger a response from a responder beacon. The time interval between the
sending and the receiving of a pulse is monitored and used to determine a
distance. In the global positioning system a code of ones and zeros is emitted at

1
a known time from multiple satellites, and their times of arrival are noted at a
receiver along with the time they were sent (encoded in the messages).
Assuming the receiver clock can be related to the synchronized clocks on the
satellites, the transit time can be found and used to provide the distance to each
satellite. Receiver clock error is corrected by combining the data from four
satellites.

Such techniques vary in accuracy according to the distances over which they are
intended for use. For example, LORAN-C is accurate to about 6 km, GPS about
10 m, enhanced GPS, in which a correction signal is transmitted from terrestrial
stations (that is, differential GPS (DGPS)) or via satellites (that is, Wide Area
Augmentation System (WAAS)) can bring accuracy to a few meters or < 1
meter, or, in specific applications, tens of centimeters. Time-of-flight systems
for robotics (for example, Laser Detection and Ranging LADAR and Light
Detection and Ranging LIDAR) aim at lengths of 10 - 100 m and have an
accuracy of about 5 – 10 mm.

In many practical circumstances, and for precision work, measurement of


dimension using transit-time measurements is used only as an initial indicator of
length and is refined using an interferometer. Generally, transit time
measurements are preferred for longer lengths, and interferometers for shorter
lengths. The ultrasonic sensor used for this project falls under the sphere of the
interferometer.

It is one thing to measure distance and another thing to display the result
accurately. No matter how sophisticated and efficient the measuring device or
technique is, if the result is not properly displayed or transmitted, errors will
come in and then cause serious issues that might be detrimental to the
equipment or the operator or both. This is why in this project, we constructed
this distance measuring device using the Arduino board (for easy and precise

2
computation of the calculated distance) and a 16” X 2” LCD display for
accurate display of the result.

1.2 AIM OF STUDY

The aim of this project is to construct a distance meter using the Arduino board,
an ultrasonic sensor and a simple Arduino code to compute the distance and
display the result on a 16” X 2” LCD.

1.3 OBJECTIVES OF THE PROJECT


 To know what an Arduino ecosystem is
 To know how the Ultrasonic Sensor/transducer can be used to measure
distance.
 to know what an LCD is and how it works.
 To develop and implement how an Arduino board can be interfaced with
and ultrasonic sensor for distance measurement.
 To have a good knowledge and understanding the Arduino IDE software
needed to control the Arduino board and shields.

1.4STAEMENT OF PROBLEM

Distance measurement has come a long way and has seen quite interesting and
sophisticated advancement, but when it comes to using the cost, it is quite
overwhelming. This problem is one of the motivating factor for undertaking this
project, to design and construct a simple distance measuring device using the
Arduino board with an ultrasonic sensor. This device is simple and accurate.

1.5LIMITATION/SCOPE OF STUDY

because of limited resources (time and finance), this project work is limited to
the construction of a simple distance meter with the capability to measure from

3
2cm up to Four Hundred Centimeters (400cm) or 4 metres. this is because our
aim is not sophistication but simplicity and accuracy.

4
CHAPTER TWO

2.0 REVIEW OF RELEVANT LITERATURES

Arduino is an open-source hardware and software company, project and user


community that designs and manufactures single-board microcontrollers and
microcontroller kits for building digital devices. In this chapter we shall be
reviewing literatures relevant to Arduino ecosystem. By ecosystem we mean the
Arduino Board, the Arduino shields and the Arduino IDE.

2.1 HISTORY OF ARDUINO

The Arduino project was started at the Interaction Design Institute Ivrea (IDII)
in Ivrea, Italy (David Kushner (2011-10-26).) At that time, the students used a
BASIC Stamp microcontroller at a cost of $50. In 2003 Hernando Barragán
created the development platform Wiring as a Master's thesis project at IDII,
under the supervision of Massimo Banzi and Casey Reas. Casey Reas is known
for co-creating, with Ben Fry, the Processing development platform. The project
goal was to create simple, low cost tools for creating digital projects by non-
engineers. The Wiring platform consisted of a printed circuit board (PCB) with
an ATmega168 microcontroller, an IDE based on Processing and library
functions to easily program the microcontroller. In 2005, Massimo Banzi, with
David Mellis, another IDII student, and David Cuartielles, extended Wiring by
adding support for the cheaper ATmega8 microcontroller. The new project,
forked from Wiring, was called Arduino.

Following the completion of the platform, lighter and less expensive versions
were distributed in the open-source community. It was estimated in mid-2011
that over 300,000 official Arduinos had been commercially produced, and in
2013 that 700,000 official boards were in users' hands.

In October 2017, Arduino announced its partnership with ARM Holdings


(ARM). The announcement said, in part, "ARM recognized independence as a

5
core value of Arduino ... without any lock-in with the ARM architecture.”
Arduino intends to continue to work with all technology vendors and
architectures.

Under Violante's guidance, the company started growing again and releasing
new designs. The Genuino trademark was dismissed and all products were
branded again with the Arduino name. As of February 2020, the Arduino
community included about 30 million active users based on the IDE downloads.

In August 2018, Arduino announced its new open source command line tool
(arduino-cli), which can be used as a replacement of the IDE to program the
boards from a shell.

In February 2019, Arduino announced its IoT Cloud service as an extension of


the Create online environment.

2.2.0 ARDUINO HARDWARE

By Arduino hardware, we mean the Arduino board itself. Simply put, the
Arduino Hardware are circuit boards that make microcontrollers easy to use.
Microcontrollers are integrated circuits (ICs) that are basically tiny Computers.
They can run small simple software programs. They are low powered enough
that they can be powered with batteries for days, yet fast enough to process data
much faster than any human being can think.

Most Arduino boards consist of an Atmel 8-bit AVR microcontroller


(ATmega8, ATmega168, ATmega328, ATmega1280, or ATmega2560) with
varying amounts of flash memory, pins, and features. The 32-bit Arduino Due,
based on the Atmel SAM3X8E was introduced in 2012. The boards use single

6
or double-row pins or female headers that facilitate connections for
programming and incorporation into other circuits. These may connect with
add-on modules termed shields.

Arduino microcontrollers are pre-programmed with a boot loader that simplifies


uploading of programs to the on-chip flash memory. The default bootloader of
the Arduino Uno is the Optiboot bootloader. Boards are loaded with program
code via a serial connection to another computer. Older serial Arduino boards
contain a level shifter circuit to
convert between RS-232 logic
levels and transistor–transistor logic
(TTL) level signals (because they
use RS232 ports). Current Arduino
boards are programmed via
Universal Serial Bus (USB), Arduino board with an RS-232 serial interface

implemented using USB-to-serial adapter chips such as the FTDI FT232. Some
boards, such as later-model Uno boards, substitute the FTDI chip with a
separate AVR chip containing USB-to-serial firmware, which is
reprogrammable via its own ICSP header.

The Arduino board exposes


most of the microcontroller's
I/O pins for use by other
circuits. The Diecimila,
Duemilanove, and current Uno
provide 14 digital I/O pins, six
of which can produce pulse-
width modulated signals, and
six analog inputs, which can
also be used as six digital I/O pins. These pins are on the top of the board, via

7
female 0.1-inch (2.54 mm) headers. Several plug-in application shields are also
commercially available.

2.2.1 OFFICIAL BOARDS

The original Arduino hardware was manufactured by the Italian company Smart
Projects. Some Arduino-branded boards have been designed by the American
companies SparkFun Electronics and Adafruit Industries. As of 2016, 17
versions of the Arduino hardware have been commercially produced.

8
2.3 ARDUINO SHIELDS

Arduino and Arduino-compatible boards use printed circuit expansion boards


called shields, which plug into the normally supplied Arduino pin headers.
Shields can provide motor controls for 3D printing and other applications,
GNSS (satellite navigation), Ethernet, liquid crystal display (LCD), or
breadboarding (prototyping). Several shields can also be made do it yourself
(DIY) with various sensors and transducers. It is the concept of these Arduino
shields that makes the Arduino ecosystem very versatile and broad in its

9
application, especially in IoT and embedded systems. Some of the common
Arduino shield configurations are:

1 Some shields offer stacking headers which allows multiple shields to be


stacked on top of an Arduino board. Here, a prototyping shield is stacked
on two Adafruit motor shield V2s.

2 Screw-terminal breakout shield in a wing-type format, allowing bare-end


wires to be connected to the board without requiring any specialized pins.

3 Adafruit Datalogging Shield with a Secure Digital (SD) card slot and real-
time clock (RTC) chip along with some space for adding components and
modules for customization.

4 Adafruit Motor Shield with screw terminals for connection to motors.


Officially discontinued, this shield may still be available through unofficial
channels.
5 The Adafruit motor shield V2 uses I²C, requiring vastly fewer digital I/O
pins than attaching each motor directly.

6 A USB host shield which allows an Arduino board to communicate with a


USB device such as a keyboard or a mouse.

10
Figure

2.4.0 ARDUINO SOFTWARE

A program for Arduino hardware may be written in any programming language


with compilers that produce binary machine code for the target processor.
Atmel provides a development environment for their 8-bit AVR and 32-bit
ARM Cortex-M based microcontrollers: AVR Studio (older) and Atmel Studio
(newer).

2.4.1 IDE

The Arduino integrated development environment (IDE) is a cross-platform


application (for Windows, macOS, and Linux) that is written in the Java
programming language. It originated from the IDE for the languages Processing
and Wiring. It includes a code editor with features such as text cutting and
pasting, searching and replacing text, automatic indenting, brace matching, and
syntax highlighting, and provides simple one-click mechanisms to compile and
upload programs to an Arduino board. It also contains a message area, a text
console, a toolbar with buttons for common functions and a hierarchy of
operation menus. The source code for the IDE is released under the GNU
General Public License, version 2.

11
The Arduino IDE supports the languages C and C++ using special rules of code
structuring. The Arduino IDE supplies a software library from the Wiring
project, which provides many common input and output procedures. User-
written code only requires two basic functions, for starting the sketch and the
main program loop, that are compiled and linked with a program stub main()
into an executable cyclic executive program with the GNU toolchain, also
included with the IDE distribution. The Arduino IDE employs the program
avrdude to convert the executable code into a text file in hexadecimal encoding
that is loaded into the Arduino board by a loader program in the board's
firmware.

2.4.2 SKETCH
A sketch is a program written with the Arduino IDE. Sketches are saved on the
development computer as text files with the file extension .ino. Arduino
Software (IDE) pre-1.0 saved sketches with the extension .pde.

A minimal Arduino C/C++ program consists of only two functions:


setup(): This function is called once when a sketch starts after power-up or
reset. It is used to initialize variables, input and output pin modes, and other
libraries needed in the sketch. It is analogous to the function main().
loop(): After setup() function exits (ends), the loop() function is executed
repeatedly in the main program. It controls the board until the board is powered
off or is reset. It is analogous to the function while(1).

12
2.4.3 LIBRARIES

The open-source nature of the Arduino project has facilitated the publication of
many free software libraries that other developers use to augment their projects.
These libraries make it easy for even a novice to use the Arduino ecosystem for
projects. It is noteworthy to state here that libraries exist for all Arduino shields,
especially the sensors/transducers. The good thing about this is that you don’t
need to spend time writing codes to enable your shields to interface with the
Arduino hardware as the libraries already exists. The “include ‘name of library”
library’ line is used to include or call up a particular library into your main code.

13
CHAPTER THREE

3.0 COMPONENTS, CONSTRUCTION AND CODING

In this chapter we will be discoursing in detail the various components used in


the construction of the project and also explain in details, the construction
process. The line of code used in programming the Arduino hardware will also
be explained.

3.1 COMPONENTS

The number of components used in the construction of this distance


measurement device are very few, thanks to the Arduino ecosystem. To achieve
this project, the following components were used:

 Arduino Board
 Arduino shield Ultrasonic Sensor
 16×2 Character LCD Module
 Breadboard
 USB Cable
 Soldering Iron
 9V Battery
 Jumper Cables

3.1.1 THE ARDUINO BOARD

For the purpose of this project, we used the most commonly used Arduino
board, the Arduino UNO Board.

The Arduino Uno is an open-source microcontroller board based on the


Microchip ATmega328P microcontroller and developed by [Link]. The
board is equipped with sets of digital and analog input/output (I/O) pins that
may be interfaced to various expansion boards (shields) and other circuits. The
board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins,

14
and is programmable with the Arduino IDE (Integrated Development
Environment), via a type B USB cable. It can be powered by the USB cable or
by an external 9-volt battery, though it accepts voltages between 7 and 20 volts.

The word "uno" means "one" in Italian and was chosen to mark the initial
release of Arduino Software. The Uno board is the first in a series of USB-
based Arduino boards; it and version 1.0 of the Arduino IDE were the reference
versions of Arduino, which have now evolved to newer releases. The
ATmega328 on the board comes preprogrammed with a bootloader that allows
uploading new code to it without the use of an external hardware programmer.

3.1.2 TECHNICAL SPECIFICATIONS

The underlisted are the technical specifications of the Arduino UNO board used
for this project.

15
Microcontroller: Microchip ATmega328P

Operating Voltage: 5 Volts

Input Voltage: 7 to 20 Volts

Digital I/O Pins: 14 (of which 6 can provide PWM output)

UART: 1

I2C: 1

SPI: 1

Analog Input Pins: 6

DC Current per I/O Pin: 20 mA

DC Current for 3.3V Pin: 50 mA

Flash Memory: 32 KB of which 0.5 KB used by bootloader

SRAM: 2 KB

EEPROM: 1 KB

Clock Speed: 16 MHz

Length: 68.6 mm

Width: 53.4 mm

Weight: 25 g

3.1.2a GENERAL PIN FUNCTIONS

LED: There is a built-in LED driven by digital pin 13. When the pin is high
value, the LED is on, when the pin is low, it is off.

VIN: The input voltage to the Arduino/Genuino board when it is using an


external power source (as opposed to 5 volts from the USB connection or other

16
regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.

5V: This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 20V), the USB
connector (5V), or the VIN pin of the board (7-20V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage the board.

3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.

GND: Ground pins.

IOREF: This pin on the Arduino/Genuino board provides the voltage reference
with which the microcontroller operates. A properly configured shield can read
the IOREF pin voltage and select the appropriate power source, or enable
voltage translators on the outputs to work with the 5V or 3.3V.

Reset: Typically used to add a reset button to shields that block the one on the
board.

3.1.2b SPECIAL PIN FUNCTIONS

Each of the 14 digital pins and 6 analog pins on the Uno can be used as an input
or output, under software control (using pinMode(), digitalWrite(), and
digitalRead() functions). They operate at 5 volts. Each pin can provide or
receive 20 mA as the recommended operating condition and has an internal
pull-up resistor (disconnected by default) of 20-50K ohm. A maximum of
40mA must not be exceeded on any I/O pin to avoid permanent damage to the
microcontroller. The Uno has 6 analog inputs, labeled A0 through A5; each
provides 10 bits of resolution (i.e. 1024 different values). By default, they
measure from ground to 5 volts, though it is possible to change the upper end of
the range using the AREF pin and the analogReference() function.

17
In addition, some pins have specialized functions: some pins have specialized
functions:

Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit
(TX) TTL serial data. These pins are connected to the corresponding pins of the
ATmega8U2 USB-to-TTL serial chip.

External interrupts: pins 2 and 3. These pins can be configured to trigger an


interrupt on a low value, a rising or falling edge, or a change in value.

PWM (pulse-width modulation): pins 3, 5, 6, 9, 10, and 11. Can provide 8-bit
PWM output with the analogWrite() function.

SPI (Serial Peripheral Interface): pins 10 (SS), 11 (MOSI), 12 (MISO), and 13


(SCK). These pins support SPI communication using the SPI library.

TWI (two-wire interface) / I²C: pin SDA (A4) and pin SCL (A5). Support TWI
communication using the Wire library.

AREF (analog reference): Reference voltage for the analog inputs.

3.1.3 COMMUNICATION

The Arduino/Genuino Uno has a number of facilities for communicating with a


computer, another Arduino/Genuino board, or other microcontrollers. The
ATmega328 provides UART TTL (5V) serial communication, which is
available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board
channels this serial communication over USB and appears as a virtual com port
to software on the computer. The 16U2 firmware uses the standard USB COM
drivers, and no external driver is needed. However, on Windows, a .inf file is
required. Arduino Software (IDE) includes a serial monitor which allows simple
textual data to be sent to and from the board. The RX and TX LEDs on the
board will flash when data is being transmitted via the USB-to-serial chip and
USB connection to the computer (but not for serial communication on pins 0

18
and 1). A SoftwareSerial library allows serial communication on any of the
Uno's digital pins.

3.1.4 THE ULTRASONIC SENSOR HC-SR04

Ultrasound is high-pitched sound waves with frequencies higher than the


audible limit of human hearing.
Human ears can hear sound waves that vibrate in the range from about 20 times
a second (a deep rumbling noise) to about 20,000 times a second (a high-pitched
whistling). However, ultrasound has a frequency of over 20,000 Hz and is
therefore inaudible to humans.

4.1.4a SPECIFICATION OF THE HC-SR04 ULTRASONIC


SENSOR

At its core, the HC-SR04 Ultrasonic distance sensor consists of two ultrasonic
transducers. The one acts as a transmitter which converts electrical signal into
40 KHz ultrasonic sound pulses. The receiver listens for the transmitted pulses.
If it receives them, it produces an output pulse whose width can be used to
determine the distance the pulse travelled.

The sensor is small, easy to use in any robotics project and offers ex
cellent non-contact range detection between 2 cm to 400 cm (that’s

19
about an inch to 13 feet) with an accuracy of 3mm. Since it operates
on 5 volts, it can be hooked directly to an Arduino or any other 5V lo
gic microcontrollers.

Here are complete specifications:

20
VCC is the power supply for HC-SR04 Ultrasonic distance sensor whi
ch we connect the 5V pin on the Arduino.
Trig (Trigger) pin is used to trigger the ultrasonic sound pulses.
Echo pin produces a pulse when the reflected signal is received. Th
e length of the pulse is proportional to the time it took for the trans
mitted signal to be detected.
GND should be connected to the ground of Arduino.

3.1.4b HOW THE HC-SR04 ULTRASONIC SENSOR WORKS


It all starts, when a pulse of at least 10 µS (10 microseconds) in
duration is applied to the Trigger pin. In response to that the sensor
transmits a sonic burst of eight pulses at 40 KHz. This 8-pulse
pattern makes the “ultrasonic signature” from the device unique,
allowing the receiver to differentiate the transmitted pattern from
the ambient ultrasonic noise.
The eight ultrasonic pulses travel through the air away from the
transmitter. Meanwhile the Echo pin
goes HIGH to start forming the
beginning of the echo-back signal.

21
In case, If those pulses are not reflected back then the Echo signal
will timeout after 38 mS (38 milliseconds) and return low. Thus a 38
mS pulse indicates no obstruction within the range of the sensor.

If those pulses are reflected back the Echo pin


goes low as soon as the signal is received. This
produces a pulse whose width varies between
150 µS to 25 mS, depending upon the time it
took for the signal to be received.

The width of the received pulse is then used to


calculate the distance to the reflected object. This can be worked out using
simple distance-speed-time equation, we learned in High school. In case you
forgot, an easy way to remember the distance, speed and time equations is to put
the letters into a triangle.

3.1.5 16×2 CHARACTER LCD MODULE

22
An LCD is short for Liquid Crystal Display. It is basically a display unit which
uses liquid crystals to produce a visible image.

When current is applied to this special kind of crystal, it turns opaque blocking
the backlight that lives behind the screen. As a result that particular area will
become dark compared to other. And that’s how characters are displayed on the
screen.

These LCDs are ideal for displaying


text/characters only, hence the name
‘Character LCD’. The display has an LED
backlight and can display 32 ASCII
characters in two rows with 16 characters
on each row.

Although they display only text, they do


come in many sizes and colors: for example, 16×1, 16×4, 20×4, with white text
on blue background, with black text on green and many more.
GND should be connected to the ground of Arduino.
VCC is the power supply for the LCD which we connect the 5 volts pin on the
Arduino.
Vo (LCD Contrast) controls the contrast and brightness of the LCD. Using a
simple voltage divider with a potentiometer, we can make fine adjustments to
the contrast.
RS (Register Select) pin lets the Arduino tell the LCD whether it is sending
commands or the data. Basically this pin is used to differentiate commands from
the data.
For example, when RS pin is set to LOW, then we are sending commands to the
LCD (like set the cursor to a specific location, clear the display, scroll the
display to the right and so on). And when RS pin is set on HIGH we are sending
data/characters to the LCD.
R/W (Read/Write) pin on the LCD is to control whether or not you’re reading
data from the LCD or writing data to the LCD. Since we’re just using this LCD

23
as an OUTPUT device, we’re going to tie this pin LOW. This forces it into the
WRITE mode.
E (Enable) pin is used to enable the display. Meaning, when this pin is set to
LOW, the LCD does not care what is happening with R/W, RS, and the data bus
lines; when this pin is set to HIGH, the LCD is processing the incoming data.
D0-D7 (Data Bus) are the pins that carries the 8 bit data we send to the display.
For example, if we want to see the uppercase ‘A’ character on the display we
will set these pins to 0100 0001(according to the ASCII table) to the LCD.
A-K (Anode & Cathode) pins are used to control the backlight of the LCD.

3.1.5 BREABOARD
Because of time constraint, we couldn’t use the PCB for our final work, so we
constructed the whole device on a white solderless breadboard. It has 2 power
buses, 10 columns, and 30 rows - a total of 400 tie in points. All pins are spaced
by a standard 0.1". The two sets of five columns are separated by about 0.3",
perfect for straddling a DIP package over. The board accepts wire sizes in the
range of 29-20AWG.
This board also has a self-adhesive on the back. The boards also have
interlocking parts, so you can hook as many together as you'd like.

24
3.1.6 PERIPHERAL COMPONENTS
A. USB CABLE
Universal Serial Bus (USB) port does
simplify connections between the
peripheral devices and your computer or
laptop. That’s why almost all electronic
devices have a USB port at which USB
cables are plugged into.
There are different types of USB cables,
but In this project, we made use of USB type B cable. B - Type is commonly
used to connect USB peripherals to transfer data from large computer devices
such as from computer to printers, some old 3.5 inches external hard disk to the
computer for data sharing, and much more. It has four contacts two laid inside
the top part and two others inside the lower part for grip and connection. You’ll
realize that type B connectors in USB 1.1 and 2.0 look the same.
B. SOLDERING IRON AND LEAD
A soldering iron is a hand tool used in soldering. It supplies heat to melt solder
so that it can flow into the joint between two workpieces. It is composed of a
heated metal tip and an insulated handle. Heating is often achieved electrically,
by passing an electric current (supplied through an electrical cord or battery
cables) through a resistive heating element.
C. 9V BATTERY
The nine-volt battery, or 9-volt battery, is a common size of battery that was
introduced for the early transistor radios. It has a rectangular prism shape with
rounded edges and a polarized snap connector at the top. This type is commonly

25
used in smoke detectors, gas detectors, clocks, walkie-talkies, electric guitars
and effects units.
We used a general purpose 9volts battery in this project. Its function is to
provide power to keep the device working independently without being
connected to the computer.
D. JUMPER CABLE
A jump wire (also known as jumper, jumper wire, jumper cable, DuPont wire or
cable) is an electrical wire, or group of them in a cable, with a connector or pin
at each end (or sometimes without them – simply "tinned"), which is normally
used to interconnect the components of a breadboard or other prototype or test
circuit, internally or with other equipment or components, without soldering.

3.2.0 CONSTRUCTION
The construction comes in two part: the circuit and the casing. The entire circuit
was constructed on the breadboad with minimal points of soldering (The
Arduino board made this possible). The type of breadboard used has self-
adhesive capabilities, providing extra safety to ensure the components remain
properly connected to the board.
The construction was carried out in one of the departmental laboratories (Power
Lab.) because of constant power supply, work bench and other working
accessories.
3.2.1 Circuit Diagram
The circuit diagram is quite simple and easy to implement. The HC-SR04
Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and
the VCC pins of the module needs to be connected to the Ground and the 5 volts
pins on the Arduino Board respectively and the trig and echo pins to any Digital

26
I/O pin on the Arduino Board. In this case we made use of the Digital I/O pins
11 and 12.
To connect the LCD, we will use just 6 digital input pins from the Arduino
Board. The LCD’s registers from D4 to D7 will be connected to Arduino’s
digital pins from 4 to 7. The Enable pin will be connected to pin number 2 and
the RS pin will be connected to pin number 1. The R/W pin will be connected to
Ground and the Vo pin will be connected to the Vcc of the Arduino board.

Like earlier said, the construction wasn’t as hectic and time consuming as the
traditional way of building circuits. The time we took inconstructing this device
was just four (6) hours. It would have been lesser, but this was our first time of
working with the Arduino ecosystem.

3.3 CODING
Coding of the Hardware was done with the Arduino IDE. The coding was
relatively simple and took lesser time when compared to the traditional way of

27
coding hardware using the C or C++ programming language. This is so because,
as we explained earlier in chapter two, the Arduino community has a host of
libraries that makes programming the various Arduino shields and sensors less
difficult.
For the purpose of time, which was not on our side, and in order not to make
this writeup too bulky and complex, we will only explain the most important
lines of the code.
3.3.1 ARDUINO IDE
The Arduino IDE was downloaded for free from [Link], installed it on
the laptop, connected our Arduino UNO board using the USB cable and then
started tup the Arduino IDE. Every
Arduino program has two areas:
The ‘setup()’ area is where you configure you Arduino to do certain things for
the duration of your programe (e.g. information on which pins are output or
which pins are input)
The ‘loop()’ is the area of the code that repeats over and over again as long as
the Arduino has power to it.

28
29
Code Explanation
The sketch starts by including LiquidCrystal library. As mentioned earlier in
this work, the Arduino community has a library called LiquidCrystal that makes
programming the LCD module less difficult.
// include the library code: Next we
#include <LiquidCrystal.h>
have to
create an
LiquidCrystal object. This object uses 6 parameters and specifies which
Arduino pins are connected to the LCD’s RS pin, Enable pin, and data pins: d4,
d5, d6, and d7.

// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

30
In the ‘setup’ function: we will use two functions: The first function is begin() .
This is used to specify the dimensions of the display i.e. how many columns and
rows the display has. Since we are using 16×2 character LCD, we pass the
parameters 16 & 2; If you are using 20×4 LCD, pass the parameters 20 & 4.
The second function is clear() .This clears the LCD screen and moves the cursor
to the upper left corner.

[Link](16, 2);

[Link]();

In the ‘loop’ function: we will use the print() function which displays the
message that we see on the first line of the screen.
The other lines of command are explained just next to the command on the
source code.

31
CHAPTER FOUR
4.0 TESTING AND RESULT
4.1.0 TESTING
Testing is very important in any project work to ensure that the device
act/behave the way it was designed to.
4.1.1 HARDWARE TESTING
We started testing right before even construction. We tested the individual
components that makes up the device to ensure that they are in good functional
state. It is good to state at this point that the main component to be tested right
before construction started was the Arduino board.
To test the board, we downloaded and installed the latest Arduino IDE and
installed it. We then connected the Arduino Board to the laptop using the USB
type B cable that came with the Arduino board on purchase and then called up
the Arduino IDE programe. The aim of this test is to:
i. Confirm that the computer can communicate with the Arduino board
(from the MENU bar select “tools’ and then ‘Boards’ to ensure you’re
your board is listed and selected).
ii. Confirm that the Arduino IDE could communicate with the Board.
(from the MENU bar, select ‘Tools’ and the sub-select ‘Ports’. The
ports can be serial or COM depending on the kind of cable you used in
interfacing the Arduino board to the computer. In our case, it was
communication port 3 (COM3)
Apart from the Arduino Board, we tested the Jumper cables used for continuity
to ensure that there were no internal damage. We used the analogue multimeter
(set to the Ohmmeter) for this test.
Also, during the Hardware construction, we took adequate precaution to ensure
that the connections were properly and accurately done. The joints/cables
soldered were done properly and also properly isolated every open joint to avoid
short circuit.

4.1.2 SOFTWARE TESTING


This test was quite straightforward. First, we tested that the Arduino software
could run on the operating system installed on the laptop. We ensured this by
downloading the IDE that is compatible with the Operating System (Windows

32
10) installed on our laptop. After downloading and installing, we launched the
software and it loaded without any hitch.
We also tested to confirm that the Arduino software could communicate with
the Arduino board, and it was successful.
We also downloaded the Library required for this project (LiquidCrystal.h) to
ensure that our software could communicate with the LCD.
Lastly, before uploading the code to the Arduino Board, we tested the code to
ensure that there were no errors/bugs to avoid malfunctioning of the device.

4.2 RESULTS
After running completing the construction and uploading the code on to the
Arduino board, we hit the RESET button and then headed on to test the project
and the results were outstanding.
On powering up the project, we discovered that the device functioned properly.
The device could measure up to 4 meters with an error margin of about 3mm. it
took a delay of less than half a second for the device to calculate the result and
display the output on the LCD.
We tested the device at various angles and inclination and discovered that the
results were accurate. We also tasted the result on various surface textures
(metal, wood, glass, etc) and discovered that the results were not affected by the
solid barriers. The result was not the same when we tested it across water
surface.
We also tested how long the 9V battery can last while continuously powering
on the device and we discovery that it can last for over 9 hours of continuous
work.

33
CHAPTER 5
SUMMARY AND RECOMMENDATION

5.1 SUMMARY

In summary, we will like to state that it was quite an interesting adventure


getting to dive into the world of the Arduino ecosystem. A lot was discovered
and learnt and there is still more to learn. Also, this Arduino a whole new
system and for that, it was not easy coming up with this project writeup.

5.2 RECOMMENDATIONS

We like to recommend that the study of this Arduino ecosystem be inculcated


into our course work in Electrical/Electronics Engineering considering the fact
that IoT and AI is projected to be the fourth industrial revolution to hit the
world. Wed say so because virtually all embedded and smart devices are
Arduino based and in this part of the world it’s still very new and little work has
been done on it. We also recommend that more projects be tailored towards the
Arduino because it is fun, easy and less complex to achieve.

34
REFERENCES
1. Jump up to:a b c d "Arduino UNO for beginners - Projects, Programming and
Parts". [Link]. Retrieved 4 February 2018.

2. [Link]

3. Jump up to:a b c "What is Arduino?". [Link]. Retrieved 4 February 2018.

4. Jump up to:a b "Introduction to Arduino" (PDF). [Link]. Archived from the


original (PDF) on 3 April 2018. Retrieved 4 February 2018.

5. "Arduino". [Link]. Retrieved 10 March 2020.

6. [Link] [Link]

7. Jump up to:a b c d e f g h official website. Content was copied from this source, which is licensed
under the Creative Commons Attribution-Share Alike 3.0 (Unported) (CC-BY-SA 3.0) license.

8. Jump up to:a b Hernando Barragán (2016-01-01). "The Untold History of


Arduino". [Link]. Retrieved 2016-03-06.

9. "Getting Started: FOUNDATION > Introduction". [Link].

10. Jump up to:a b c David Kushner (2011-10-26). "The Making of Arduino". IEEE Spectrum.

11. Justin Lahart (27 November 2009). "Taking an Open-Source Approach to Hardware". The Wall
Street Journal. Retrieved 2014-09-07.

12. Jump up to:a b Hernando Barragán (2016-01-01). "The Untold History of


Arduino". [Link]. Retrieved 2016-03-06.

13. "How many Arduinos are "in the wild?" About 300,000". Adafruit Industries. May 15, 2011.
Retrieved 2013-05-26.

14. "Arduino FAQ – With David Cuartielles". Malmö University. April 5, 2013. Retrieved 2014-03-24.

15. "Business Entity Summary for Arduino LLC". [Link]. State of Massachusetts.

16. Allan, Alasdair (6 March 2015). "Arduino Wars: Group Splits, Competing Products
Revealed?". [Link]. Maker Media, Inc. Retrieved 21 April 2015.

17. Banzi, Massimo (19 March 2015). "Massimo Banzi: Fighting for Arduino". [Link]. Maker
Media, Inc. Retrieved 21 April2015.

18. Williams, Elliot (28 March 2015). "Arduino SRL to Distributors: "We're the Real
Arduino"". [Link]. [Link]. Retrieved 21 April 2015.

19. "Arduino LLC vs Arduino SRL lawsuit; United States Courts Archive". Archived from the original on
2017-07-09. Retrieved 20 February 2018.

20. "Arduino Announces New Brand, Genuino, Manufacturing Partnership with Adafruit". Make. 16
May 2015. Retrieved 17 May2015.

35
36

You might also like