You are on page 1of 56

ARDUINO BASED ROAD CROSSING SAFETY SIGNAL

SYSTEM

A PROJECT REPORT

Submitted by
AKSHAY.N.M
MOHAMED SHAMIL NALAKATH
RISHIRAJ.A.R
SANOOP.E.S

In partial fulfillment for the award of the degree of


BACHELOR OF ENGINEERING
IN
ELECTRICAL AND ELECTRONICS ENGINEERING
EASA COLLAGE OF ENGINEERING AND TECHNOLOGY
ANNA UNIVERSITY: CHENNAI 600 025

JUNE 2022
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE

Certified that this project report “ARDUINO BASED ROAD CROSSING


SAFETY SIGNAL SYSTEM” is the bonafide work of “AKSHAY.N.M
(720518105001), MOHAMED SHAMIL NALAKATH (720518105005),
RISHIRAJ.A.R (720518105009), SANOOP.E.S (720518105010)” who carried
out the project work under my supervision.

SIGNATURE SIGNATURE
Dr. N.Kaleeswari Prof.G.RANJITH KUMAR
HEAD OF THE DEPARTMENT SUPERVISOR
DEPARTMENT OF ELECTRICAL DEPARTMENT OF ELECTRICA
&ELECTRONICS ENGINEERING & ELECTRONICS ENGINEERING
EASA COLLAGE OF ENGINEERING EASA COLLAGE OF
ENGINEERING
AND TECHNOLOGY AND TECHNOLOGY

Submitted for the project viva voice examination held on___________

INTERNAL EXAMINER EXTERNAL


EXAMINER
iv
ACKNOWLEDGEMENT

We take this opportunity to express our gratitude and deep regard to our
guide Mr. G.Ranjith Kumar, Associate Professor, Department of
Electrical and Electronics Engineering, for his guidance, monitoring and
constant encouragement throughout the course of this project. His
invaluable guidance and immense help are embodied in this dissertation.
We also express our sincere gratitude to Dr. N.Kaleeswari, Head of the
Department, Department of Electrical and Electronics Engineering for
her keen interest and unfailing inspiration throughout the course of the
project.
We are thankful to the staff of Department of Electrical and Electronics
Engineering for providing all kinds of support in the lab and helping us
throughout the work.
We are also grateful to the institute's laboratory and other facilities for
providing us with required resources for the completion of this project.
Finally we thank all those who are involved, directly or indirectly,
throughout the course of the project.
ABSTRACT

Everyday many lives are lost due to accidents on roads. Pedestrians are


particularly at risk in traffic. Walking and bicycling are fundamental
modes of transportation. However, more than 2000 cyclists and 7000
pedestrians were killed annually in the European Union. The situation
was even worse in the emerging and developing countries like India and
China. Their rapid economic growths increase travel demand, but
overwhelm the limited transportation infrastructure.
The traffic in these developing countries is characterized by a wide mix
of vehicle types and pedestrians that differ substantially in their
dimensions, performance capabilities and driver behavior. These
situations greatly challenge the availability and feasibility of Advanced
Driver Assistance Systems (ADAS). To avoid crashes with cyclists and
pedestrians, it is critical to detect the moving objects to help car drivers
notice them when they are around the vehicle. In most accidents, the
pedestrian collides with the front of the vehicle.

The requirement of Pedestrian detection and vehicle is an essential and


significant task in any intelligent road safety systems, especially during
night times. Traffic safety data reveal that the majority of preventable
pedestrian fatalities occurred at night.

The lack of light at night may cause dysfunction of sensors like


cameras. This paper proposes an alternative approach to detect traffic
participants using cost-effective ultrasonic sensors. In this proposed
system, ultrasonic sensor based pedestrian and vehicle detection is
implemented. Ultrasonic sensors installed in the road sides are an active
technology designed to alert drivers to the presence of pedestrians
crossing the road and the passengers the vehicles coming their way.

iii
TABLE OF CONTENTS

CHAPTER TITLE PAGE


NO
NO
ABSTRACT iii
LIST OF FIGURES vii
LIST OF TABLES vii
LIST OF ABBREVIATIONS ix

1 INTRODUCTION 1
1.1 Arduino UNO 1
1.2 ATMEGA 328p 4
1.2.1 Technical specification 4
1.2.2 Pin configuration 5
1.2.2.1 ADC pins 5
1.2.2.2 Pinout - Digital pins 6
1.2.3 Software 12
1.2.3.1 IDE 13
1.2.3.2 IDE 2.0 14
1.2.3.3 SKETCH 15
1.2.3.4 Communication 16

iv
1.2.3.5 Automatic (Software) 16
Reset

2 LITERATURE REVIEW 17
3 COMPONENTS 18
3.1 PIR sensor 18
3.1.1 Principle 21
3.1.2 Advantages 21
3.1.3 Disadvantages 22
3.2 Ultrasonic sensor 23
(HC-SR04)
3.2.1 Functioning 25
3.2.2 HC-SR04 into Arduino 26
3.3 HC-05 Core Bluetooth 27
Module
3.3.1 Features 30
3.3.2 Specifications 30
3.4 Buck Converter 31
4 PROGRAMMING 33
4.1 Pedestrian side 33
4.2 Vehicle side 35
5 WORKING PRINCIPLE 38
5.1 Pedestrian side 39

v
5.2 Vehicle side 40
5.3 Stimulation Result 41
6 CONCLUSION 42
REFRENCES 43

vi
LIST OF FIGURES

FIGURE TITLE PAGE


NO
NO

1.1 Arduino UNO 3


1.2 ICSP Header 9
3.1.1 PIR range 19
3.1.2 PIR waveform 20
3.2.1 Ultrasonic sensor 25
3.3.1 HC-05 module 28
3.4.1 Buck Converter 32
Circuit
5.1 Circuit diagram 38
5.1.1 Pedestrian side 39
block diagram
5.2.1 Vehicle side 40
block diagram

vii
LIST OF TABLES

TABLE TITLE PAGE NO


NO

1.1 Pin configuration 11

5.3.1 Stimulation Result 41

viii
LIST OF ABBREVIATION

 GND : Ground
 TXD : Transmitting Data
 RXD : Receiving Data
 SCK : Serial clock
 MISO : Master In Slave Out
 ICSP : In-Circuit Serial Programming
 SCL : Serial Clock Pin
 SPI : Serial Peripheral Interface
 MOSI : Master Out Slave I

ix
CHAPTER 1
INTRODUCTION

1.1 ARDUINO UNO:

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.
Arduino board designs use a variety of microprocessors and controllers.
The boards are equipped with sets of digital and analog input/output
(I/O) pins that may be interfaced to various expansion boards (‘shields’)
or breadboards (for prototyping) and other circuits. The boards feature
serial communications interfaces, including Universal Serial Bus (USB)
on some models, which are also used for loading programs. The
microcontrollers can be programmed using the C and C++ programming
languages, using a standard API which is also known as the Arduino
language, inspired by the Processing language and used with a modified
version of the Processing IDE. In addition to using traditional compiler
toolchains, the Arduino project provides an integrated development
environment (IDE) and a command line tool developed in Go.
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.
[30] The boards use single 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.
1
Multiple and possibly stacked shields may be individually addressable
via an I2C serial bus. Most boards include a 5 V linear regulator and a
16 MHz crystal oscillator or ceramic resonator. Some designs, such as
the Lily Pad, run at 8 MHz and dispense with the onboard voltage
regulator due to specific form-factor restrictions.
Although the hardware and software designs are freely available under
copy left licenses, the developers have requested the name Arduino to be
exclusive to the official product and not be used for derived works
without permission. The official policy document on use of the Arduino
name emphasizes that the project is open to incorporating work by
others into the official product. Several Arduino-compatible products
commercially released have avoided the project name by using various
names ending in -duino.
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. Some serial Arduino boards contain a level shifter circuit to
convert between RS-232 logic levels and transistor–transistor logic
(TTL) level signals. Current Arduino boards are programmed via
Universal Serial Bus (USB), 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. Other variants, such as the Arduino Mini and the unofficial
Boarduino, use a detachable USB-to-serial adapter board or cable,
Bluetooth or other methods. When used with traditional microcontroller
tools, instead of the Arduino IDE, standard AVR in-system
programming (ISP) programming is used.

2
Fig 1.1. Arduino UNO

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 female 0.1-
inch (2.54 mm) headers. Several plug-in application shields are also
commercially available. The Arduino Nano, and Arduino-compatible
Bare Bones Board and Boarduino boards may provide male header pins
on the underside of the board that can plug into solderless breadboards.
Many Arduino-compatible and Arduino-derived boards exist. Some are
functionally equivalent to an Arduino and can be used interchangeably.
Many enhance the basic Arduino by adding output drivers, often for use

3
in school-level education, to simplify making buggies and small robots.
Others are electrically equivalent, but change the form factor, sometimes
retaining compatibility with shields, sometimes not. Some variants use
different processors, of varying compatibility.

1.2 ATMEGA 328p:

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


Microchip ATmega328P microcontroller and developed by Arduino.cc.
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, 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. It is similar to the Arduino
Nano and Leonardo. The hardware reference design is distributed under
a Creative Commons Attribution Share-Alike 2.5 license and is available
on the Arduino website. Layout and production files for some versions
of the hardware are also available.

1.2.1 Technical specification:

 Microcontroller: Microchip ATmega328P[7]


 Operating Voltage: 5 Volts
 Input Voltage: 7 to 20 Volts
 Digital I/O Pins: 14 (of which 6 can provide PWM output)
 PWM Pins: 6 (Pin # 3, 5, 6, 9, 10 and 11)[9]
 UART: 1
 I2C: 1
4
 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
 ICSP Header: Yes
 Power Sources: DC Power Jack & USB Port

1.2.2 Pin Configuration:

The Arduino Uno has 6 analog pins, which utilize ADC (Analog to
Digital converter). These pins serve as analog inputs but can also
function as digital inputs or digital outputs.

1.2.2.1 ADC Pins:

ADC stands for Analog to Digital Converter. ADC is an electronic


circuit used to convert analog signals into digital signals. This digital
representation of analog signals allows the processor (which is a digital
device) to measure the analog signal and use it through its operation.

Arduino Pins A0-A5 are capable of reading analog voltages. On Arduino


the ADC has 10-bit resolution, meaning it can represent analog voltage

5
by 1,024 digital levels. The ADC converts voltage into bits which the
microprocessor can understand.

One common example of an ADC is Voice over IP (VoIP). Every


smartphone has a microphone that converts sound waves (voice) into
analog voltage. This goes through the device’s ADC, gets converted into
digital data, which is transmitted to the receiving side over the internet.

1.2.2.2 Pinout – Digital Pins:

Pins 0-13 of the Arduino Uno serve as digital input/output pins. Pin 13
of the Arduino Uno is connected to the built-in LED. In the Arduino
Uno – pins 3, 5,6,9,10,11 have PWM capability. It’s important to note
that:

● Each pin can provide/sink up to 40 mA max. But the recommended


current is 20 mA.
● The absolute max current provided (or sank) from all pins together
is 200mA.

Digital is a way of representing voltage in 1 bit: either 0 or 1. Digital


pins on the Arduino are pins designed to be configured as inputs or
outputs according to the needs of the user. Digital pins are either on or
off. When ON they are in a HIGH voltage state of 5V and when OFF
they are in a LOW voltage state of 0V.

On the Arduino, When the digital pins are configured as output, they are
set to 0 or 5 volts. When the digital pins are configured as input, the

6
voltage is supplied from an external device. This voltage can vary
between 0-5 volts which is converted into digital representation (0 or 1).
To determine this, there are 2 thresholds:

● Below 0.8v – considered as 0.


● Above 2v – considered as 1.

When connecting a component to a digital pin, make sure that the logic
levels match. If the voltage is in between the thresholds, the returning
value will be undefined.

o Voltage Regulator
The voltage regulator converts the input voltage to 5V. The primary
function of voltage regulator is to regulate the voltage level in the
Arduino board. For any changes in the input voltage of the regulator, the
output voltage is constant and steady.

o GND – Ground pins.


The ground pins are used to ground the circuit.

o TXD and RXD


TXD and RXD pins are used for serial communication. The TXD is used
for transmitting the data, and RXD is used for receiving the data. It also
represents the successful flow of data.
o USB Interface

7
The USB Interface is used to plug-in the USB cable. It allows the board
to connect to the computer. It is essential for the programming of the
Arduino UNO board.

o RESET
It is used to add a Reset button to the connection.

o SCK
It stands for Serial Clock. These are the clock pulses, which are used to
synchronize the transmission of data.

o MISO
It stands for Master Input/ Slave Output. The save line in the MISO pin
is used to send the data to the master.

o VCC
It is the modulated DC supply voltage, which is used to regulate the IC’s
used in the connection. It is also called as the primary voltage for IC’s
present on the Arduino board. The Vcc voltage value can be negative or
positive with respect to the GND pin.

o Crystal Oscillator
The Crystal oscillator has a frequency of 16MHz, which makes the
Arduino UNO a powerful board.
o ICSP

8
It stands for In-Circuit Serial Programming. The users can program the
Arduino board’s firmware using the ICSP pins. The program or
firmware with the advanced functionalities is received by
microcontroller with the help of the ICSP header. The ICSP header
consists of 6 pins. The structure of the ICSP header is shown below:

Fig 1.2 ICSP Header

o SDA
It stands for Serial Data. It is a line used by the slave and master to send
and receive data. It is called as a data line, while SCL is called as a clock
line.

o SCL
It stands for Serial Clock. It is defined as the line that carries the clock
data. It is used to synchronize the transfer of data between the two
devices. The Serial Clock is generated by the device and it is called as
master.

9
o SPI
It stands for Serial Peripheral Interface. It is popularly used by the
microcontrollers to communicate with one or more peripheral devices
quickly. It uses conductors for data receiving, data sending,
synchronization, and device selection (for communication).

o MOSI
It stands for Master Output/ Slave Input. The MOSI and SCK are driven
by the Master.

o SS
It stands for Slave Select. It is the Slave Select line, which is used by the
master. It acts as the enable line.

o I2C
It is the two-wire serial communication protocol. It stands for Inter
Integrated Circuits. The I2C is a serial communication protocol that uses
SCL (Serial Clock) and SDA (Serial Data) to receive and send data
between two devices. 3.3V and 5V are the operating voltages of the
board.

10
Pin Category Pin Name Details
Power Vin, 3.3V, 5V, GND Vin: Input voltage to
Arduino when using
an external power
source.
5V: Regulated power
supply used to power
microcontroller and
other components on
the board.
3.3V: 3.3V supply
generated by on-board
voltage regulator.
Maximum current
draw is 50mA.
GND: ground pins.
Reset Reset Resets the
microcontroller.
Analog Pins A0 – A5 Used to provide
analog input in the
range of 0-5V
Input/Output Pins Digital Pins 0 – 13 Can be used as input
or output pins.
Serial 0(Rx), 1(Tx) Used to receive and
transmit TTL serial
data.
External Interrupts 2, 3 To trigger an
interrupt.

11
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM
output.
SPI 10 (SS), 11 (MOSI), Used for SPI
12 (MISO) and 13 communication.
(SCK)
Inbuilt LED 13 To turn on the inbuilt
LED.
TWI A4 (SDA), A5 (SCA) Used for TWI
communication.
AREF AREF To provide reference
voltage for input
voltage.

Table 1.1 Pin Configuration

1.2.3 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).

1.2.3.1 IDE:

12
The Arduino integrated development environment (IDE) is a cross-
platform application (for Microsoft 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.
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 argued 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.
Integrated development environments are designed to maximize
programmer productivity by providing tight-knit components with
similar user interfaces. IDEs present a single program in which all
development is done. This program typically provides many features for
authoring, modifying, compiling, deploying and debugging software.
This contrasts with software development using unrelated tools, such as
VI, GDB, GCC, or make.
One aim of the IDE is to reduce the configuration necessary to piece
together multiple development utilities. Instead, it provides the same set

13
of capabilities as one cohesive unit. Reducing setup time can increase
developer productivity, especially in cases where learning to use the IDE
is faster than manually integrating and learning all of the individual
tools. Tighter integration of all development tasks has the potential to
improve overall productivity beyond just helping with setup tasks. For
example, code can be continuously parsed while it is being edited,
providing instant feedback when syntax errors are introduced, thus
allowing developers to debug code much faster and more easily with an
IDE.
Some IDEs are dedicated to a specific programming language, allowing
a feature set that most closely matches the programming paradigms of
the language. However, there are many multiple-language IDEs.
While most modern IDEs are graphical, text-based IDEs such as Turbo
Pascal were in popular use before the availability of windowing systems
like Microsoft Windows and the X Window System (X11). They
commonly use function keys or hotkeys to execute frequently used
commands or macros.
From version 1.8.12, Arduino IDE windows compiler supports only
Windows 7 or newer OS. On Windows Vista or older one gets
“Unrecognized Win32 application” error when trying to verify/upload
program. To run IDE on older machines, users can either use version
1.8.11, or copy “Arduino-builder” executable from version 11 to their
current install folder as its independent from IDE.

1.2.3.2 IDE 2.0:

On March 1, 2021, the beta preview was released, renamed IDE 2.0. The
system still uses Arduino CLI (Command Line Interface), but
improvements include a more professional development environment,
auto completion support, and Git integration. The application frontend is
14
based on the Eclipse Theia Open Source IDE. The main features
available in the new release are:
o Modern, fully featured development environment
o Dual Mode, Classic Mode (identical to the Classic Arduino IDE)
and Pro Mode (File System view)
o New Board Manager
o New Library Manager
o Board List
o Basic Auto-Completion (Arm targets only)
o Git Integration
o Serial Monitor
o Dark Mode

1.2.3.3 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:

o 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().
o 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

15
1.2.3.4 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 and 1). A Software Serial library allows serial
communication on any of the Uno’s digital pins.
1.2.3.5 Automatic (software) reset:

Rather than requiring a physical press of the reset button before an


upload, the Arduino/Genuino Uno board is designed in a way that allows
it to be reset by software running on a connected computer. One of the
hardware flow control lines (DTR) of the ATmega8U2/16U2 is
connected to the reset line of the ATmega328 via a 100 nan farad
capacitor. When this line is asserted (taken low), the reset line drops
long enough to reset the chip.
This setup has other implications. When the Uno is connected to a
computer running Mac OS X or Linux, it resets each time a connection
is made to it from software (via USB). For the following half-second or
so, the bootloader is running on the Uno. While it is programmed to
ignore malformed data (i.e. anything besides an upload of new code), it

16
will intercept the first few bytes of data sent to the board after a
connection is opened
CHAPTER 2
LITERATURE REVIEW

1) “Getting Started: FOUNDATION > Introduction”. Arduino.cc.


Archived from the original on 2017-08-29. Retrieved 2017-05-23.
2) David Kushner (2011-10-26). “The Making of Arduino”. IEEE
Spectrum.
3) Justin Lahart (27 November 2009). “Taking an Open-Source
Approach to Hardware”. The Wall Street Journal. Retrieved
2014-09-07.
4) Hernando Barragán (2016-01-01). “The Untold History of
Arduino”. Arduinohistory.github.io. Retrieved 2016-03-06.
5) “How many Arduinos are “in the wild?” About 300,000”.
Adafruit Industries. May 15, 2011. Retrieved 2013-05-26.
6) “Arduino FAQ – With David Cuartielles”. Malmö University.
April 5, 2013. Archived from the original on 2017-09-06.
Retrieved 2014-03-24.
7) “Business Entity Summary for Arduino LLC”. Mass.gov. State
of Massachusetts.
8) Allan, Alasdair (6 March 2015). “Arduino Wars: Group Splits,
Competing Products Revealed?”. Makezine.com. Maker Media,
Inc. Retrieved 21 April 2015.

17
CHAPTER 3
COMPONENTS

3.1 PIR sensor:


PIR (Pyroelectric (“Passive”) Infrared) Sensors PIR sensors
allow you to sense motion, almost always used to detect whether a
human has moved in or out of the sensors range. They are small,
inexpensive, low-power, easy to use and don't wear out. For that reason
they are commonly found in appliances and gadgets used in homes or
businesses. They are often referred to as PIR, "Passive Infrared",
"Pyroelectric", or "IR motion" sensors.
PIRs are basically made of a pyroelectric sensor (which you can
see below as the round metal can with a rectangular crystal in the
center), which can detect levels of infrared radiation. Everything emits
some low level radiation, and the hotter something is, the more radiation
is emitted. The sensor in a motion detector is actually split in two halves.
The reason for that is that we are looking to detect motion (change) not
average IR levels. The two halves are wired up so that they cancel each
other out. If one half sees more or less IR radiation than the other, the
output will swing high or low.
Along with the pyroelectric sensor is a bunch of supporting circuitry,
resistors and capacitors. It seems that most small hobbyist sensors use
the BISS0001 (“Micro Power PIR Motion Detector IC”), undoubtedly a
very inexpensive chip. This chip takes the output of the sensor and does

18
some minor processing on it to emit a digital output pulse from the
analog sensor.
Our new PIRs have more adjustable settings and have a header installed
in the 3-pin ground/out/power pads
PIR sensors are more complicated than many of the other sensors
explained in these tutorials (like photocells, FSRs and tilt switches)
because there are multiple variables that affect the sensors input and
output. To begin explaining how a basic sensor works, we’ll use this
rather nice diagram.

Fig 3.1.1 PIR range

The PIR sensor itself has two slots in it, each slot is made of a special
material that is sensitive to IR. The lens used here is not really doing
much and so we see that the two slots can ‘see’ out past some distance
(basically the sensitivity of the sensor). When the sensor is idle, both
slots detect the same amount of IR, the ambient amount radiated from
19
the room or walls or outdoors. When a warm body like a human or
animal passes by, it first intercepts one half of the PIR sensor, which
causes a positive differential change between the two halves. When the
warm body leaves the sensing area, the reverse happens, whereby the
sensor generates a negative differential change. These change pulses are
what is detected.
For many basic projects or products that need to detect when a person
has left or entered the area, or has approached, PIR sensors are great.
They are low power and low cost, pretty rugged, have a wide lens range,
and are easy to interface with. Note that PIRs won’t tell you how many
people are around or how close they are to the sensor, the lens is often
fixed to a certain sweep and distance (although it can be hacked
somewhere) and they are also sometimes set off by house pets.

20
Fig 3.1.2 PIR Waveform

The different faceting and sub-lenses create a range of detection areas,


interleaved with each other. That’s why the lens centers in the facets
above are ‘inconsistent’ – every other one points to a different half of the
PIR sensing element.

3.1.1 Principle:

All the objects, living things having a temperature


more than absolute zero emit infrared radiations in their surroundings.
Warmer the object, more the infrared radiations are emitted.
The PIR sensor is a thermal infrared sensor (IR Sensor) which detects
the motion of objects on reading these infrared radiations’ variations in
its nearby environment.
The sensor has two equal slots made up of
Pyroelectric material that is very sensitive to Infrared. When the sensor
is not active, both its slots sense the same amount of Infrared radiations
coming from any object, door or wall, etc.
When a warm body comes in the range of the PIR motion
sensor, it passes through both the slots one after the other. The moment
it intercepts the first half of the sensor, a positive differential change is
caused between the two halves. Similarly, when it leaves the detection
area a negative differential change occurs between both the slots. These
changes in the pulses are the indication to the sensor that there is some
motion in its detecting zone.

3.1.2 Advantages:

21
 PIR motion sensors can detect moving objects even in dark with
great accuracy.
 PIR sensors can detect the motion of objects without coming in
contact with them.
 They are very easy to install and do not require much wiring.
 They reduce a lot of human efforts by making things to work
automatically.
 They consume very less energy and thus reduce electricity bills a
lot.

3.1.3 Disadvantages:

 They have lower sensitivity and less coverage compare to


microwave sensors.
 It does not operate greater than 35 degree C.
 It works effectively in LOS (Line of Sight) and will have problems
in the corner regions.
 It is insensitive to very slow motion of the objects.
 PIR motion sensors are a bit costly and cannot be afforded by a
majority of people.
 PIR sensors sometimes behave abnormally during bad weather
conditions.
 PIR sensors sometimes become incapable of detecting a very slow-
moving object.
 Home security systems with PIR motion detectors sometimes
trigger false alarms due to no reason.
 PIR motion sensors have a very short detection range and thus
sometimes it leads to a loophole in Burglar alarm systems because
of incomplete coverage issue.

22
3.2 Ultrasonic sensor (HC-SR04):

An ultrasonic sensor is an electronic device that measures the distance of


a target object by emitting ultrasonic sound waves, and converts the
reflected sound into an electrical signal. Ultrasonic waves travel faster
than the speed of audible sound (i.e. the sound that humans can hear).
Ultrasonic sensors have two main components: the transmitter (which
emits the sound using piezoelectric crystals) and the receiver (which
encounters the sound after it has travelled to and from the target).
In order to calculate the distance between the sensor and the object, the
sensor measures the time it takes between the emissions of the sound by
the transmitter to its contact with the receiver. The formula for this
calculation is D = ½ T x C (where D is the distance, T is the time, and C
is the speed of sound ~ 343 meters/second). For example, if a scientist
set up an ultrasonic sensor aimed at a box and it took 0.025 seconds for
the sound to bounce back, the distance between the ultrasonic sensor and
the box would be:
D = 0.5 x 0.025 x 343
Or about 4.2875 meters.
Ultrasonic sensors are used primarily as proximity sensors. They can be
found in automobile self-parking technology and anti-collision safety
systems. Ultrasonic sensors are also used in robotic obstacle detection
systems, as well as manufacturing technology. In comparison to infrared
(IR) sensors in proximity sensing applications, ultrasonic sensors are not
as susceptible to interference of smoke, gas, and other airborne particles
(though the physical components are still affected by variables such as
heat).
23
Ultrasonic sensors are also used as level sensors to detect, monitor, and
regulate liquid levels in closed containers (such as vats in chemical
factories). Most notably, ultrasonic technology has enabled the medical
industry to produce images of internal organs, identify tumors, and
ensure the health of babies in the womb.
Ultrasonic sensors work by emitting sound waves at a frequency too
high for humans to hear. They then wait for the sound to be reflected
back, calculating distance based on the time required. This is similar to
how radar measures the time it takes a radio wave to return after hitting
an object.
While some sensors use a separate sound emitter and receiver, it’s also
possible to combine these into one package device, having an ultrasonic
element alternate between emitting and receiving signals. This type of
sensor can be manufactured in a smaller package than with separate
elements, which is convenient for applications where size is at a
premium.
While radar and ultrasonic sensors can be used for
some of the same purposes, sound-based sensors are readily available—
they can be had for just a couple dollars in some cases—and in certain
situations, they may detect objects more effectively than radar. For
instance, while radar, or even light-based sensors, have a difficult time
correctly processing clear plastic, ultrasonic sensors have no problem
with this. In fact, they’re unaffected by the color of the material they are
sensing.
On the other hand, if an object is made out of a material that absorbs
sound or is shaped in such a way that it reflects the sound waves away
from the receiver, readings will be unreliable. If you need to measure the
specific distance from your sensor, this can be calculated based on this
formula:
Distance = ½ T x C

24
(T = Time and C = the speed of sound)

At 20°C (68°F), the speed of sound is 343 meters/second (1125


feet/second), but this varies depending on temperature and humidity.
Specially adapted ultrasonic sensors can also be used underwater. The
speed of sound, however, is 4.3 times as fast in water as in air, so this
calculation must be adjusted significantly.

3.2.1 Functioning:
So where can we use these sensors? Robot navigation comes to mind, as
well as factory automation. Water-level sensing is another good use, and
can be accomplished by positioning one sensor above a water surface.
Another aquatic application is to use these sensors to “see” the bottom of
a body of water, traveling through the water, but reflecting off the
bottom surface below.

25
Fig 3.2.1 Ultrasonic sensor

Though it might not be immediately obvious, if configured correctly


ultrasonic sensors can even measure fluid flow rates. In the simplest
case, an emitter and a receiver (separate in this configuration) are
aligned with the flow of a fluid.
Since sound is traveling through a moving medium, the speed of sound
relative to these elements will be increased or decreased by the velocity
of the fluid. This can be applied to flow inside pipes by aligning these
two elements at an angle to each other, calculating the effective velocity
increase based on the trigonometric relations between the two.
Flowrate accuracy can be increased by using data from
multiple ultrasonic elements, giving results accurate to within a fraction
of a percent.

3.2.2 HC-SR04 into Arduino:

If this all sounds interesting, you can try it out yourself very easily using
an Arduino and an HC-SR04 sensor. Shown above is the compact and
inexpensive Arduino Nano, but any other development board should
also work. Gather the components (Arduino, HC-SR04, wires, and
breadboard) and go into the Arduino IDE and install the “NewPing”
sensor library.
Once installed, there will be a number of new example sketches you can
choose from. Open up the “NewPing3Sensors” sketch. Attach pins from
your Arduino to the HC-SR04, as defined in the program, adding ground
and 5V from the Arduino.
Send the program to your dev board, and then open up a serial monitor
at 115200 baud. You’ll see a distance reading when you put something

26
in front of it. Note that it reads “0” when it doesn’t properly read a
distance.
Send the program to your dev board, and then open up a serial monitor
at 115200 baud. You’ll see a distance reading when you put something
in front of it. Note that it reads “0” when it doesn’t properly read a
distance.
Try experimenting with different shapes and
materials to see what works and what doesn’t. I was pleased to find that
acoustic foam paneling does not return a signal, while flat smooth
surfaces like a phone screen or piece of paper are sensed quite well.
Ultrasonic transducers operate at frequencies in the range of 30–
500 kHz for air-coupled applications. As the ultrasonic frequency
increases, the rate of attenuation increases. Thus, low-frequency sensors
(30–80 kHz) are more effective for long range, while high-frequency
sensors are more effective for short range.

3.3 HC-05 Core Bluetooth module:

HC-05 is a Bluetooth module designed for


establishing short range wireless data communication between two
microcontrollers or systems. The module works on Bluetooth 2.0
communication protocol and it can only act as a slave device. This is
cheapest method for wireless data transmission and more flexible
compared to other methods and it even can transmit files at speed up to
2.1Mb/s. HC-05 uses frequency hopping spread spectrum technique
(FHSS) to avoid interference with other devices and to have full duplex
transmission. The device works on the frequency range from 2.402 GHz
to 2.480GHz.

27
Fig 3.3.1 HC-05 module

After connecting the module you have to write the program in Arduino
IDE to receive and send data to the module.
The communication with this HC-05 module is done through UART
interface. The data is sent to the module or received from the module
though this interface. So we can connect the module to any
microcontroller or directly to PC which has RS232 port (UART
interface). Here the module is connected to +5V standard regulated
power supply and UART interface is established as shown in figure. All
you need to do is connect RXD of Arduino to TXD of module and TXD
of Arduino is connected to RXD of module through a resistor voltage
divider.
This voltage divider is provided for converting 5V logic signal sent by
Arduino to +3.3V logic signals which are suitable for the module. The
ground of Arduino and module must be connected for voltage reference
in case separate power sources are used. For successful wireless
communication you need to remember a few things:

28
 In programming you need to set default baud rate of UART serial
communication to 9600. The value is default setting of module and
can be change in program.
 The module is a slave and so you need a master to establish a
successful wireless interface. For that you need another [Arduino +
module (with master feature)] setup or you can use a smart phone
as a master and search for HC-05 slave.
 The master searches for slave and connects to it after authenticated
with password. The HC-05 module has default password ‘1234’
which can be changed.
 In program you can receive data master sends (After
authentication) and perform tasks based on it.
 Also you can download libraries for module through the websites
and use them to make communication easy. All you need to do is
download these libraries and call them in programs. Once the
header file is included, you can use simple commands in the
program to tell the Arduino to send or receive data. The module
sends this data to master through wireless Bluetooth. If the module
receives any data from master, it will transmit it to Arduino
through UART serial communication.
 You can also interface HC-05 to PC using RS232 cable. Once you
interface is done you can use serial terminal on PC or any similar
software to send or receive data to module. You need to type in AT
command in serial terminal to communicate with the module and
these commands can be downloaded.

After you change the baud rate, if it is not the default 9600, you need to
use the setting baud rate in future parameter setting or data
communication. It is recommended that you do not use the baud rate
greater than 115200. The interference of signals will make the system
unstable. You cannot use your computer if you set a baud rate higher
than 115200. You should program with SCM to make the baud rate

29
higher than 115200 so as to use this baud rate and resent AT command
to set a low rate.

3.3.1 Features:
 The module is very easy to interface and to communicate.
 HC-05 is best option when short distance wireless
communication is needed. The module is used for wireless
communications of less than 100 meters.
 The module is one of the cheapest solutions for wireless
communication of all types present in the market.
 The module consumes very less power to function and can be
used on battery operated mobile systems. • The module can
be interfaced with almost all controllers or processors as it
uses UART interface

3.3.2 Specifications:

 Bluetooth protocol: Bluetooth V2.0 protocol standard


 Power Level: Class2(+6dBm)
 Band: 2.40GHz—2.48GHz, ISM Band
 Receiver sensitivity: -85dBm
 USB protocol: USB v1.1/2.0
 Modulation mode: Gauss frequency Shift Keying
 Safety feature: Authentication and encryption
 Operating voltage range:+3.3V to +6V
 Operating temperature range: -20ºC to +55ºC
 Operating Current: 40mA

30
3.4 Buck converters:

A buck converter (step-down converter) is a DC-to-DC power converter


which steps down voltage (while drawing less average current) from its
input (supply) to its output (load). It is a class of switched-mode power
supply (SMPS) typically containing at least two semiconductors (a diode
and a transistor, although modern buck converters frequently replace the
diode with a second transistor used for synchronous rectification) and at
least one energy storage element, a capacitor, inductor, or the two in
combination.
To reduce voltage ripple, filters made of capacitors (sometimes in
combination with inductors) are normally added to such a converter’s
output (load-side filter) and input (supply-side filter).[1] It is called a
buck converter because the voltage across the inductor “bucks” or
opposes the supply voltage.
Switching converters (such as buck
converters) provide much greater power efficiency as DC-to-DC
converters than linear regulators, which are simpler circuits that lower
voltages by dissipating power as heat, but do not step up output current.
The efficiency of buck converters can be very high, often over 90%,
making them useful for tasks such as converting a computer’s main
supply voltage, which is usually 12 V, down to lower voltages needed
by USB, DRAM and the CPU, which are usually 5, 3.3 or 1.8 V.

31
Fig 3.4.1 Buck converter circuit

Fig. 3.4.1 the two circuit configurations of a


buck converter: on-state, when the switch is closed; and off-state, when
the switch is open (arrows indicate current according to the direction
conventional current model).
The basic operation of the buck converter has the current in an inductor
controlled by two switches (usually a transistor and a diode). In the
idealized converter, all the components are considered to be perfect.
Specifically, the switch and the diode have zero voltage drop when on
and zero current flow when off, and the inductor has zero series
resistance. Further, it is assumed that the input and output voltages do
not change over the course of a cycle, which would imply the output
capacitance as being infinite.

32
CHAPTER 4
PROGRAMMING

Arduino is the hardware platform used to teach the C


programming language as Arduino boards are available worldwide and
contain the popular AVR microcontrollers from Atmel.
Atmel Studio is used as the development environment
for writing C programs for AVR microcontrollers. It is a full-featured
integrated development environment (IDE) that uses the GCC C
software tools for AVR microcontrollers and is free to download.
Arduino programs are written in the Arduino Integrated
Development Environment (IDE). Arduino IDE is a special software
running on your system that allows you to write sketches (synonym for
program in Arduino language) for different Arduino boards. The
Arduino programming language is based on a very simple hardware
programming language called processing, which is similar to the C
language.
The first step in programming the Arduino board is downloading and
installing the Arduino IDE. Download the Arduino software (depending
on your OS) from the official website and follow the instructions to
install.

4.1 Pedestrian side:

#include <SoftwareSerial.h>
#include <HCSR04.h>

33
#define tx 3
#define rx 2
SoftwareSerial configBt(rx, tx); // RX, TX
UltraSonicDistanceSensor distanceSensor(11, 12);
Void setup()
{
Serial.begin(9600);
configBt.begin(9600);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
pinMode(8, INPUT);
pinMode(13, OUTPUT);
}
Void loop()
{ char c;
Bool flag;
Int Level = distanceSensor.measureDistanceCm();
//Serial.println(Level);
If (configBt.available()) // if the HC05 is sending something…
{
C = configBt.read();
Serial.print©; // print in serial monitor
}

34
If (c == ‘a’)
{
digitalWrite(13, 1);
//flag = true;
}
Else if (c == ‘b’)
{
digitalWrite(13, 0);
//flag = true;
}
If (digitalRead(8)==1&&Level < 10 && Level != -1)
{
Serial.print(“OK”);
configBt.print(“a”);
}
Else
{
configBt.print(“b”);
}
Delay(1000);
}

4.2 Vehicle side:

35
#include <SoftwareSerial.h>
#include <HCSR04.h>
#define tx 3
#define rx 2
SoftwareSerial configBt(rx, tx); // RX, TX
UltraSonicDistanceSensor distanceSensor(11, 12);
Void setup()
{
Serial.begin(9600);
configBt.begin(9600);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
// pinMode(8, INPUT);
pinMode(13, OUTPUT);
}
Void loop()
{ char c;
Bool flag;
Int Level = distanceSensor.measureDistanceCm();
//Serial.println(Level);
If (configBt.available()) // if the HC05 is sending something…
{

36
C = configBt.read();
Serial.print©; // print in serial monitor
}
If (c == ‘a’)
{
digitalWrite(13, 1);
//flag = true;
}
Else if (c == ‘b’)
{
digitalWrite(13, 0);
//flag = true;
}
If (Level < 10 && Level != -1)
{
Serial.print(“OK”);
configBt.print(“a”);
}
Else
{
configBt.print(“b”);
}
Delay(1000);

37
}

CHAPTER 5
WORKING PRINCIPLE

Microcontroller at the pedestrian side and vehicle side control the whole
operations. Arduino Uno is used as microcontroller unit. The Arduino
programming is done for 5 sec of time period it can be alternated by
alternating the program. The system consist of two circuit one for
pedestrian side and another vehicle side. The two circuit are place on
two dotted type breadboards and they should maintain a minimum
distance of 15 centimeters for an effective communication between the
Bluetooth modules. The basic diagram for two circuit is given below:

38
Fig 5.1 Circuit diagram:

5.1 Pedestrian side:

On considering the pedestrian side, the circuit is


made on a bread board and all the components are assembled in the
circuit. PIR sensor at the pedestrian unit detect presence of human by
sensing the humidity of human. Using ultrasonic sensor (HCSR04) the
system confirms the presence of human and transmit the information to
the system. Once human presence is confirmed, the information is
transmitted through the Bluetooth module (HC-05) at pedestrian side.
The information is received at the Bluetooth module in vehicle unit and
the LED lights at the vehicle unit turned ON by turning into red to alert
the vehicles on human presence in the front.

POWER SUPPLY

BLUETOOTH

PIR SENSOR

LED WARNING
ARDUINO UNO
LIGHT
ULTRASONIC
SENSOR

Fig 5.1.1 Pedestrian side block diagram

39
5.2 Vehicle side:

On the vehicle side the process will be similar to that of


pedestrian side. The only difference is that there will be no PIR sensor.
Similarly, once the ultrasonic sensor at the vehicle unit detects a vehicle,
the information is passed through the Bluetooth module at vehicle side.
The information is received by the Bluetooth module at
pedestrian side and LED lights at the pedestrian unit turned ON to alert
the pedestrians on arrival of a vehicle on the road. The block diagram for
the following circuit is given below:

POWER SUPPLY

PEDESTRIAN LED
WARNING LIGHT

ULTRASONIC
SENSOR ARDUINO UNO
BLUETOOTH

Fig 5.2.1 Vehicle side block diagram

40
5.3 Stimulation Result:

The stimulation result for the above circuit diagram is given below as a
table for the simplicity:

Pedestrian Side Vehicle Side Indication Result


1 0 Red Waring for the
vehicle to slow
down.
0 1 Red Care should be
taken while
crossing the
road.
1 1 Red Care should be
taken while
crossing the
road
Table 5.3.1 Stimulation Result

41
CHAPTER 6
CONCLUSION

Through this work, we got more information about the Arduino and
microcontroller ATMEGA 328P and its function and specifications. By
using this methodology, we could develop a safety signal system for the
pedestrian to cross the road especially during the night period. Our main
motive was to reduce the count of accidents.

42
REFRENCES

[1] V. E. Dahiphale and S. R. Rao, “A Review paper on Portable Driver


Monitoring System for Real Time Fatigue,” 2015 International
Conference on Computing Communication Control and Automation,
Pune, 2015, pp. 558-560.

[2] T. Tangkocharoen and A. Srisuphab, “Vehicle detection on a pint-


sized Computer,” 2017 9th International Conference on Knowledge and
Smart Technology (KST), Chonburi, 2017, pp. 40-44.

[3] T. Sorwar, S. B. Azad, S. R. Hussain and A. I. Mahmood, “Real-time


Vehicle monitoring for traffic surveillance and adaptive change
detection
Using Raspberry Pi camera module,” 2017 IEEE Region 10
Humanitarian
Technology Conference (R10-HTC), Dhaka, 2017, pp. 481-484.

[4] Mr. AvinashGadekar, Mr. Paresh Joshi, Mr. Ravindra Ardhapure,


Mr.
Shankar Waghmare, Prof. Namrata Jadhao, “Review: Smart Traffic
Signal Management System using Image Processing”, International
Research Journal of Engineering and Technology (IRJET) Volume: 04
Issue: 10, October 2017.

[5] A. P. Kulkarni and V. P. Baligar, “Real Time Vehicle Detection,


Tracking and Counting Using Raspberry-Pi,” 2020 2nd International
Conference on Innovative Mechanisms for Industry Applications
(ICIMIA), Bangalore, India, 2020, pp. 603-607.
43
[6] E. Ospina, E. Tascon, J. Valencia, and C. Madrigal, “Traffic flow
control. Using artificial vision techniques,” 2011 6 th Colombian
Computing Congress (CCC), Manizales, 2011, pp. 1-4.

[7] M. Soleh, G. Jati, A. T. Sasongko, W. Jatmiko, and M. H. Hilman,


“A
Real time vehicle counting based on adaptive tracking approach for

Highway videos,” 2017 International Workshop on Big Data and


Information Security (IWBIS), Jakarta, 2017, pp. 93-98.

[8] M. F. Chowdhury, M. Ryad Ahmed Biplob and J. Uddin, “Real Time


Traffic Density Measurement using Computer Vision and Dynamic
Traffic Control,” 2018 Joint 7th International Conference on Informatics,
Electronics & Vision (ICIEV) and 2018 2nd International Conference on
Imaging, Vision & Pattern Recognition (icIVPR), Kitakyushu, Japan,
2018, pp. 353-356.

[9] Amartya Kalapahar, March 2018, www.github.com/amartya-k/vision

[10] Pedro Henrique Fonseca Bertoleti, “Counting objects in movement


using Open CV and Raspberry Pi”, 2017 December, www.hackster.io

[11] www.smartmotorist.com/average-car-length

44
45

You might also like