Sais Document
Sais Document
ON
By
MADIREDDY SAI 21R91A04E0
K. CHANDANA 21R91A049B7
G. VIGNESH 21R91A0483
G. JEEVAN 21R91A0475
This is to certify that the Mini Project work entitled “SMART ROAD SAFETY
The satisfaction and euphoria the accompanies the successful completion of any task would be
incomplete without the mention of the people who made it possible and whose encouragement and
guidance have crowned our efforts with success.
First, We would like to thank our Mini Project guide Mrs. B. Rekha, Associate Professor in
Department of E.C.E., for her inspiration, adroit guidance and constructive criticism for completion of
our degree.
We would like to convey our special thanks to the Minor Project Co-Ordinator Mrs. Dr. E.
RADHAMMA, Associate Professor in Department of E.C.E., for her valuable guidance and
suggestions in analyzing and testing throughout the period, till the end of this work completion.
Also, we would like to express our sincere gratitude to Dr. SK. UMAR FARUQ. Professor Head
of Department in Electronics & Communication Engineering during the progress of the Project work,
for his timely suggestions and help in spite of his busy schedule.
We would like to convey our special gratitude to the Vice-Principal and Dean of Academics at
Teegala Krishna Reddy Engineering College Dr. B. SRINIVASA RAO, Professor in Department of
ECE., for his inspiration, adroit guidance and constructive criticism for completion of this work.
Our acknowledgement extended to Principal Dr. K.V. MURALI MOHAN, Principal of
TEEGALA KRISHNA REDDY ENGINEERING COLLEGE for his
consistent help and encouragement to complete the research work.
We are very much thankful to TKR EDUCATIONAL SOCIETY on behalf of our beloved
Chairman Sri TEEGALA KRISHNA REDDY Garu for their help in providing good facilities in our
college.
ABSTRACT
LIST OF FIGURES
CHAPTER 1: INTRODUCTION 1-2
1.3 Thesis 2
3.1.2 ATmega328 9
3.2.1 Introduction. 19
3.3 LED. 27
3.4 IR sensor. 29
i
CHAPTER 4: SOFTWARE DESCRIPTION 37-41
ii
ABSTRACT
The main aim of this project is to design a vehicle accident prevention system using Arduino
and IR sensors.
Growth in population has led to growth in technology. People use car on large number and
number of accidents taking place, is increasing day-by-day. Road accidents are undoubtedly the most
frequent happening cases and overall, the cause of the most damage. There are many dangerous roads
in the world like mountain roads, narrow curve roads, T roads. Some mountain roads are very narrow
and they have many curves. The problems in these curve roads are that the drivers are not able to see
the vehicle or obstacles coming from another end of the curve. If the vehicle is in great speed, then it
is difficult to control and there are chances of falling off a cliff. Hence there is a need of many road
safety systems. To avoid these problems in curve roads of mountain areas, we have proposed this
vehicle accident prevention system.
iii
LIST OF FIGURES
iv
6.1 Initially Both 42
6.2 Vehicle from left side of the road 43
6.3 vehicle from right side of the road 43
6.4 Both vehicles are each other 44
v
LIST OF ABBREVIATIONS
vi
CHAPTER 1
INTRODUCTION
1.1 Introduction:
The main aim of this project is to design a vehicle accident prevention system using Arduino
and IR sensors.
Growth in population has led to growth in technology. People use car on large number and
number of accidents taking place, is increasing day-by-day. Road accidents are undoubtedly the most
frequent happening cases and overall, the cause of the most damage. There are many dangerous roads
in the world like mountain roads, narrow curve roads, T roads. Some mountain roads are very narrow
and they have many curves. The problems in these curve roads are that the drivers are not able to see
the vehicle or obstacles coming from another end of the curve. If the vehicle is in great speed, then it
is difficult to control and there are chances of falling off a cliff. Hence there is a need of many road
safety systems. To avoid these problems in curve roads of mountain areas, we have proposed this
vehicle accident prevention system.
The main controlling device of the project is Arduino UNO Microcontroller. This project
makes a use of IR sensors, green and red LED lights. When two cars pass from the opposite side of a
mountain curve the IR sensor senses the car and process this signal to the microcontroller then the
microcontroller turn on the RED LED which can gives the indication of oppositive side of the vehicle.
And then it changes one LED color into green to allow the one car to pass and then the other LED
color turns green. In this way we can prevent the accidents of curved road. The status of the project
will display on LCD. To achieve this task Arduino loaded program written in embedded C language.
1
1.2 Project Overview:
The thesis explains the implementation of “Smart Road Safety and Vehicle Accident
Prevention System for Mountain Roads” using Arduino uno microcontroller. The organization of
the thesis is explained here with:
Chapter 1 Presents introduction to the overall thesis and the overview of the project. In the project
overview a brief introduction of Smart Road Safety and Vehicle Accident Prevention System for
Mountain Roads and its applications are discussed.
Chapter 2 Presents the topic embedded systems. It explains the about what is embedded systems,
need for embedded systems, explanation of it along with its applications.
Chapter 3 Presents the hardware description. It deals with the block diagram of the project and
explains the purpose of each block. In the same chapter the explanation of microcontroller, power
supplies, IR transmitter and IR receiver, LCD display and LEDs are considered.
Chapter 4 Presents the software description. It explains the implementation of the project using
Arduino IDE Compiler software.
Chapter 7 Presents the results, conclusion and future scope of the project.
2
CHAPTER 2
BLOCK DIAGRAM
2.1 Introduction:
The block diagram of the project and design aspect of independent modules are considered.
Block diagram is shown in fig: 2.1:
FIG 2.1: Block diagram of Smart Road Safety and Vehicle Accident Prevention System for
Mountain Roads
In this chapter, schematic diagram and interfacing of Arduino uno microcontroller with each
module is considered.
3
Fig 2.2: Schematic diagram of Smart Road Safety and Vehicle Accident Prevention System for
Mountain Roads
The above schematic diagram of Smart Road Safety and Vehicle Accident Prevention System
for Mountain Roads system explains the interfacing section of each component with micro controller
and IR sensors.
4
CHAPTER 3
HARDWARE DESCRIPTION
The Arduino Uno is a microcontroller board which has ATmega328 from the AVR family.
There are 14 digital input/output pins, 6 Analog pins and 16MHz ceramic resonator.
USB connection, power jack and also a reset button is used. Its software is supported by
a number of libraries, which makes the programming easier.
ATMEGA328:
Features
5
• Advanced RISC Architecture
(ATmega48PA/88PA/168PA/328P)
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby,
6
and Extended Standby
• Operating Voltage:
• Temperature Range:
– -40°C to 85°C
• Speed Grade:
7
VCC Digital
supply voltage.
GND
Ground.
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each it).
The Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if
the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as input to
the inverting Oscillator amplifier and input to the internal clock operating circuit. Depending on the
clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier.
If the Internal Calibrated RC Oscillator is used as chip clock source, PB7.6 is used as
TOSC2.1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. The various
special features of Port B are elaborated in” Alternate Functions of Port B” on page 82 and” System
Clock and Clock Options” on page 26.
Port C (PC5:0)
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each it).
The PC5.0 output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if
the clock is not running.
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical
characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is un
8
programmed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse
length will generate a Reset, even if the clock is not running.
The minimum pulse length is given in Table 28-3 on page 318. Shorter pulses are not
guaranteed to generate a Reset. The various special features of Port C are elaborated in” Alternate
Functions of Port C” on page 85.
Port D (PD7:0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port D output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if
the clock is not running. The various special features of Port D are elaborated in” Alternate Functions
of Port D” on page88.
AVCC
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected
to VCC through a low-pass filter. Note that PC6.4 use digital supply voltage, VCC.
AREF
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to the A/D converter.
These pins are powered from the analog supply and serve as 10-bit ADC channels.
3.1.2 ATmega328
Overview
9
ATmega48PA/88PA/168PA/328P achieves throughputs approaching 1 MIPS per MHz allowing the
system designer to optimize power consumption versus processing speed.
The AVR core combines a rich instruction set with 32 general purpose working registers. All
the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than
conventional CISC microcontrollers
1
three flexible Timer/Counters with compare modes, internal and external interrupts, a serial
programmable
1
USART, a byte-oriented 2-wire Serial Interface, an SPI serial port, a 6-channel 10-bit ADC (8
channels in TQFP and QFN/MLF packages), a programmable Watchdog Timer with internal
Oscillator, and five software selectable power saving modes. The Idle mode stops the CPU while
allowing the SRAM, Timer/Counters, USART, 2-wire Serial Interface, SPI port, and interrupt system
to continue functioning. The Power-down mode saves the register contents but freezes the Oscillator,
disabling all other chip functions until the next interrupt or hardware reset.
1
Fig 3.5 block diagram of AVR architecture
In order to maximize performance and parallelism, the AVR uses a Harvard architecture –
with separate memories and buses for program and data. Instructions in the program memory are
executed with a single level pipelining. While one instruction is being executed, the next instruction is
pre-fetched from the program memory. This concept enables instructions to be executed in every
clock cycle. The program memory is In-System Reprogrammable Flash memory.
The fast-access Register File contains 32 x 8-bit general purpose working registers with a
single clock cycle access time. This allows single-cycle Arithmetic Logic Unit (ALU) operation. In a
typical ALU operation, two operands are output from the Register File, the operation is executed, and
the result is stored back in the Register File – in one clock cycle. Six of the 32 registers can be used as
three 16- bit indirect address register pointers for Data Space addressing – enabling efficient address
calculations. One of these address pointers can also be used as an address pointer for look up tables in
Flash program
1
memory. These added function registers are the 16-bit X-, Y-, and Z-register, described later in this
section.
The ALU supports arithmetic and logic operations between registers or between a constant and
a register. Single register operations can also be executed in the ALU. After an arithmetic operation,
the Status Register is updated to reflect information about the result of the operation.
Program flow is provided by conditional and unconditional jump and call instructions, able to
directly address the whole address space. Most AVR instructions have a single 16-bit word format.
Every program memory address contains a 16- or 32-bit instruction.
Program Flash memory space is divided in two sections, the Boot Program section and the
Application Program section. Both sections have dedicated Lock bits for write and read/write
protection. The SPM instruction that writes into the Application Flash memory section must reside in
the Boot Program section.
During interrupts and subroutine calls, the return address Program Counter (PC) is stored on
the Stack. The Stack is effectively allocated in the general data SRAM, and consequently the Stack
size is only limited by the total SRAM size and the usage of the SRAM. All user programs must
initialize the SP in the Reset routine (before subroutines or interrupts are executed). The Stack Pointer
(SP) is read/write accessible in the I/O space. The data SRAM can easily be accessed through the five
different addressing modes supported in the AVR architecture.
The memory spaces in the AVR architecture are all linear and regular memory maps.
A flexible interrupt module has its control registers in the I/O space with an additional Global
Interrupt Enable bit in the Status Register. All interrupts have a separate Interrupt Vector in the
Interrupt Vector table. The interrupts have priority in accordance with their Interrupt Vector position.
The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers,
SPI, and other I/O functions. The I/O Memory can be accessed directly, or as the Data Space
locations following those of the Register File, 0x20 - 0x5F. In addition, the
ATmega48PA/88PA/168PA/328P has Extended I/O space from 0x60 - 0xFF in SRAM where only
the ST/STS/STD and LD/LDS/LDD instructions can be used.
1
ALU – Arithmetic Logic Unit
The high-performance AVR ALU operates in direct connection with all the 32 general purpose
working registers. Within a single clock cycle, arithmetic operations between general purpose
registers or between a register and an immediate are executed. The ALU operations are divided into
three main categories – arithmetic, logical, and bit-functions. Some implementations of the
architecture also provide a powerful multiplier supporting both signed/unsigned multiplication and
fractional format. See the “Instruction Set” section for a detailed description.
Status Register
The Status Register contains information about the result of the most recently executed
arithmetic instruction. This information can be used for altering program flow in order to perform
conditional operations. Note that the Status Register is updated after all ALU operations, as specified
in the Instruction Set Reference. This will in many cases remove the need for using the dedicated
compare instructions, resulting in faster and more compact code. The Status Register is not
automatically stored when entering an interrupt routine and restored when returning from an interrupt.
This must be handled by software.
AVR Memories
Overview
1
The Flash memory has an endurance of at least 10,000 write/erase cycles. The
ATmega48PA/88PA/168PA/328P Program Counter (PC) is 11/12/13/14 bits wide, thus addressing
the 2/4/8/16K program memory locations. The operation of Boot Program section and associated
Boot Lock bits for software protection are described in detail in” Self-Programming the Flash,
ATmega48PA” on page 269 and” Boot Loader Support – Read-While-Write Self-Programming,
ATmega88PA, ATmega168PA and ATmega328P” on page 277.” Memory Programming” on page
294 contains a detailed description on Flash Programming in SPI- or Parallel Programming mode.
Constant tables can be allocated within the entire program memory address space (see the
LPM – Load Program Memory instruction description).
The five different addressing modes for the data memory cover: Direct, Indirect with
Displacement, Indirect, Indirect with Pre-decrement, and Indirect with Post-increment. In the Register
File, registers R26 to R31 feature the indirect addressing pointer registers.
The direct addressing reaches the entire data space. The Indirect with Displacement mode
reaches 63 address locations from the base address given by the Y- or Z-register.
When using register indirect addressing modes with automatic pre-decrement and post-
increment, the address registers X, Y, and Z are decremented or incremented. The 32 general purpose
working registers, 64 I/O Registers, 160 Extended I/O Registers, and the 512/1024/1024/2048 bytes of
internal data SRAM in the ATmega48PA/88PA/168PA/328P are all accessible through all these
addressing modes.
1
EEPROM Data Memory
Let’s the user software detect when the next byte can be written. If the user code contains instructions
that write the EEPROM, some precautions must be taken. In heavily filtered power supplies, VCC is
likely to rise or fall slowly on power-up/down. This causes the device for some period of time to run
at a voltage lower than specified as minimum for the clock frequency used. In order to prevent
unintentional EEPROM writes, a specific write procedure must be followed. Refer to the description
of the EEPROM Control Register for details on this. When the EEPROM is read, the CPU is halted
for four clock cycles before the next instruction is executed. When the EEPROM is written, the CPU
is halted for two clock cycles before the next instruction is executed.
Pins XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which
can be configured for use as an On-chip Oscillator, either a quartz crystal or a ceramic resonator may
be used. This Crystal Oscillator is a low power oscillator, with reduced voltage swing on the XTAL2
output.
It gives the lowest power consumption, but is not capable of driving other clock inputs, and may be
more susceptible to noise in noisy environments. C1 and C2 should always be equal for both crystals
and resonators. The optimal value of the capacitors depends on the crystal or resonator in use, the
amount of stray capacitance, and the electromagnetic noise of the environment. For ceramic
resonators, the capacitor values given by the manufacturer should be used.
1
Fig 3.5 Crystal oscillator connection
Watchdog Timer
Features
• 3 Operating modes
o Interrupt
o System Reset
Overview
In Interrupt mode, the WDT gives an interrupt when the timer expires. This interrupt can be
used to wake the device from sleep-modes, and also as a general system timer. One example is to limit
1
the maximum time allowed for certain operations, giving an interrupt when the operation has run
longer
1
than expected. In System Reset mode, the WDT gives a reset when the timer expires. This is typically
used to prevent system hang-up in case of runaway code. The third mode, Interrupt and System Reset
mode, combines the other two modes by first giving an interrupt and then switch to System Reset
mode. This mode will for instance allow a safe shutdown by saving critical parameters before a
system reset.
The Watchdog always on (WDTON) fuse, if programmed, will force the Watchdog Timer to
System Reset mode. With the fuse programmed the System Reset mode bit (WDE) and Interrupt
mode bit (WDIE) are locked to 1 and 0 respectively. To further ensure program security, alterations to
the Watchdog set-up must follow timed sequences. The sequence for clearing WDE and changing
time-out configuration is as follows:
1. In the same operation, write a logic one to the Watchdog change enable bit (WDCE) and WDE. A
logic one must be written to WDE regardless of the previous value of the WDE bit.
2. Within the next four clock cycles, write the WDE and Watchdog prescaler bits (WDP) as desired,
but with the WDCE bit cleared. This must be done in one operation.
The following code example shows one assembly and one C function for turning off the
Watchdog Timer. The example assumes that interrupts are controlled (e.g. by disabling interrupts
globally) so that no interrupts will occur during the execution of these functions.
Features
Frequency Generator
2
Overview
CPU accessible I/O Registers, including I/O bits and I/O pins, are shown in bold.
3.2.1 Introduction:
Conversion of one form of electrical power to another desired form and voltage, typically
involving converting AC line voltage to a well-regulated lower-voltage DC for electronic devices.
Low voltage, low power DC power supply units are commonly integrated with the devices they
supply, such as computers and household electronics.
Batteries.
Chemical fuel cells and other forms of energy storage systems.
Solar power.
Generators or alternators.
3.2.2 Block Diagram:
2
The basic circuit diagram of a regulated power supply (DC O/P) with led connected as
load is shown in fig: 3.7
Fig 3.8 Circuit diagram of Regulated Power Supply with Led connection
230V AC MAINS
TRANSFORMER
BRIDGE RECTIFIER(DIODES)
CAPACITOR
VOLTAGE REGULATOR (IC 7805)
RESISTOR
LED (LIGHT EMITTING DIODE)
The detailed explanation of each and every component mentioned above is as follows:
Transformation: The process of transforming energy from one device to another is called
transformation. For transforming energy, we use transformers.
Transformers:
A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its frequency. A varying current in the first
or primary winding creates a varying magnetic flux in the transformer's core, and thus a
2
varying magnetic field through the secondary winding. This varying magnetic field induces a
varying electromotive force (EMF) or "voltage" in the secondary winding. This effect is called mutual
induction.
If a load is connected to the secondary, an electric current will flow in the secondary winding
and electrical energy will be transferred from the primary circuit through the transformer to the load.
This field is made up from lines of force and has the same shape as a bar magnet.
If the current is increased, the lines of force move outwards from the coil. If the current is
reduced, the lines of force move inwards.
If another coil is placed adjacent to the first coil then, as the field moves out or in, the moving
lines of force will "cut" the turns of the second coil. As it does this, a voltage is induced in the second
coil. With the 50 Hz AC mains supply, this will happen 50 times a second. This is called MUTUAL
INDUCTION and forms the basis of the transformer.
The input coil is called the PRIMARY WINDING; the output coil is the SECONDARY
WINDING. Fig: 3.9 shows step-down transformer.
For example, if the secondary has half the primary turns; the secondary will have half
the
primary voltage.
2
Another example is if the primary has 5000 turns and the secondary has 500 turns, then the
turn’s ratio is 10:1.
If the primary voltage is 240 volts then the secondary voltage will be x 10 smaller = 24 volts.
Assuming a perfect transformer, the power provided by the primary must equal the power taken by a
load on the secondary. If a 24-watt lamp is connected across a 24 volt secondary, then the primary
must supply 24 watts.
To aid magnetic coupling between primary and secondary, the coils are wound on a metal
CORE. Since the primary would induce power, called EDDY CURRENTS, into this core, the core is
LAMINATED. This means that it is made up from metal sheets insulated from each other.
Transformers to work at higher frequencies have an iron dust core or no core at all.
Note that the transformer only works on AC, which has a constantly changing current and
moving field. DC has a steady current and therefore a steady field and there would be no induction.
Some transformers have an electrostatic screen between primary and secondary. This is to
prevent some types of interference being fed from the equipment down into the mains supply, or in
the other direction. Transformers are sometimes used for IMPEDANCE MATCHING.
Step Up transformer:
In case of step-up transformer, primary windings are every less compared to secondary
winding. Because of having more turns secondary winding accepts more energy, and it releases more
voltage at the output side.
In case of step-down transformer, Primary winding induces more flux than the secondary
winding, and secondary winding is having a smaller number of turns because of that it accepts a
smaller number of fluxes, and releases less amount of voltage.
2
Rectification:
The process of converting an alternating current to a pulsating direct current is called as rectification.
For rectification purpose we use rectifiers
The Bridge rectifier circuit is shown in fig: 3.10, which converts an ac voltage to dc voltage
using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The
circuit has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally
opposite ends of the bridge. The load resistance is connected between the other two ends of the bridge.
For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes D2
and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance RL
and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and
D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load resistance RL and
hence the current flows through R L in the same direction as in the previous half cycle. Thus, a bi-
directional wave is converted into a unidirectional wave.
Input Output
2
DB107:
Now -a -days Bridge rectifier is available in IC with a number of DB107. In our project
we are using an IC in place of bridge rectifier. The picture of DB 107 is shown in fig: 3.11.
Features:
Filtration:
The process of converting a pulsating direct current to a pure direct current using filters is
called as filtration.
Filters:
Electronic filters are electronic circuits, which perform signal-processing functions, specifically
to remove unwanted frequency components from the signal, to enhance wanted ones.
2
Introduction to Capacitors:
The Capacitor or sometimes referred to as a Condenser is a passive device, and one which
stores energy in the form of an electrostatic field which produces a potential (static voltage) across its
plates. In its basic form a capacitor consists of two parallel conductive plates that are not connected
but are electrically separated either by air or by an insulating material called the Dielectric. When a
voltage is applied to these plates, a current flows charging up the plates with electrons giving one
plate a positive charge and the other plate an equal and opposite negative charge this flow of electrons
to the plates is known as the Charging Current and continues to flow until the voltage across the plates
(and hence the capacitor) is equal to the applied voltage Vcc. At this point the capacitor is said to be
fully charged and this is illustrated below. The construction of capacitor and an electrolytic capacitor
are shown in figures
3.12 and 3.13 respectively.
Regulation:
2
regulation. For the process of regulation, we use voltage regulators.
2
Voltage Regulator:
A voltage regulator (also called a ‘regulator’) with only three terminals appears to be a simple
device, but it is in fact a very complex integrated circuit. It converts a varying input voltage into a
constant ‘regulated’ output voltage. Voltage Regulators are available in a variety of outputs like 5V,
6V, 9V, 12V and 15V. The LM78XX series of voltage regulators are designed for positive input. For
applications requiring negative input, the LM79XX series is used. Using a pair of ‘voltage-divider’
resistors can increase the output voltage of a regulator circuit.
It is not possible to obtain a voltage lower than the stated rating. You cannot use a 12V
regulator to make a 5V power supply. Voltage regulators are very robust. These can withstand over-
current draw due to short circuits and also over-heating. In both cases, the regulator will cut off before
any damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input.
Reverse polarity destroys the regulator almost instantly. Fig: 3.14 shows voltage regulator.
Resistors:
A resistor is a two-terminal electronic component that produces a voltage across its terminals
that is proportional to the electric current passing through it in accordance with Ohm's law:
V = IR
2
Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most
electronic equipment. Practical resistors can be made of various compounds and films, as well as
resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).
The primary characteristics of a resistor are the resistance, the tolerance, maximum working
voltage and the power rating. Other characteristics include temperature coefficient, noise, and
inductance. Less well-known is critical resistance, the value below which power dissipation limits the
maximum permitted current flow, and above which the limit is applied voltage. Critical resistance is
determined by the design, materials and dimensions of the resistor.
Resistors can be made to control the flow of current, to work as Voltage dividers, to dissipate
power and it can shape electrical waves when used in combination of other components. Basic unit is
ohms.
3.3. LED:
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator
lamps in many devices, and are increasingly used for lighting. Introduced as a practical electronic
component in 1962, early LEDs emitted low-intensity red light, but modern versions are available
across the visible, ultraviolet and infrared wavelengths, with very high brightness. The internal
structure and parts of a led are shown in figures 3.15(a) and 3.15(b) respectively.
3
Working:
The structure of the LED light is completely different than that of the light bulb. Amazingly, the LED
has a simple and strong structure. The light-emitting semiconductor material is what determines the
LED's color. The LED is based on the semiconductor diode.
When a diode is forward biased (switched on), electrons are able to recombine with holes
within the device, releasing energy in the form of photons. This effect is called electroluminescence
and the color of the light (corresponding to the energy of the photon) is determined by the energy gap
of the semiconductor. An LED is usually small in area (less than 1 mm 2), and integrated optical
components are used to shape its radiation pattern and assist in reflection. LED’s present many
advantages over incandescent light sources including lower energy consumption, longer lifetime,
improved robustness, smaller size, faster switching, and greater durability and reliability. However,
they are relatively expensive and require more precise current and heat management than traditional
light sources. Current LED products for general lighting are more expensive to buy than fluorescent
lamp sources of comparable output. They also enjoy use in applications as diverse as replacements for
traditional light sources in automotive lighting (particularly indicators) and in traffic signals. The
compact size of LED’s has allowed new text and video displays and sensors to be developed, while
their high switching rates are useful in advanced communications technology. The electrical symbol
and polarities of led are shown in fig: 3.16.
Visual signal application where the light goes more or less directly from the LED to the
human eye, to convey a message or meaning.
Illumination where LED light is reflected from object to give visual response of these objects.
Generate light for measuring and interacting with processes that do not involve the human
visual system.
3.4 IR sensor:
IR Sensor Module:
3
Pin Configuration:
3
The IR sensor module consists mainly of the IR Transmitter and Receiver, Op-amp, Variable
Resistor (Trimmer pot), output LED in brief.
IR LED Transmitter:
IR LED emits light, in the range of Infrared frequency. IR light is invisible to us as its
wavelength (700nm – 1mm) is much higher than the visible light range. IR LEDs have light emitting
angle of approx. 20-60 degree and range of approx. few centimeters to several feet’s, it depends upon
the type of IR transmitter and the manufacturer. Some transmitters have the range in kilometers. IR
LED white or transparent in color, so it can give out amount of maximum light.
Photodiode Receiver:
Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode is a
semiconductor which has a P-N junction, operated in Reverse Bias, means it start conducting the
current in reverse direction when Light falls on it, and the amount of current flow is proportional to
the amount of Light. This property makes it useful for IR detection. Photodiode looks like a LED,
with a black colour coating on its outer side, Black colour absorbs the highest amount of light.
Obstacle Detection
Industrial safety devices
Wheel encoder
3
3.5 LCD display:
LCD Background:
One of the most common devices attached to a micro controller is an LCD display. Some of the most
common LCDs connected to the many microcontrollers are 16x2 and 20x2 displays. This means 16
characters per line by 2 lines and 20 characters per line by 2 lines, respectively.
Pin description:
3
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)
The LCD requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may
select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is
used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an
8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for
the data bus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that we are sending it data. To
send data to the LCD, our program should make sure this line is low (0) and then set the other two
control lines and/or put data on the data bus. When the other lines are completely ready, bring EN
high
(1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to
LCD), and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the
data being sent is text data which should be displayed on the screen. For example, to display the letter
"T" on the screen we would set RS high.
The RW line is the "Read/Write" control line. When RW is low (0), the information on the data
bus is being written to the LCD. When RW is high (1), the program is effectively querying (or
reading)
3
3
the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands-
-so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by
the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4,
DB5, DB6, and DB7.
Schematic:
Circuit Description:
Above is the quite simple schematic. The LCD panel's Enable and Register Select is connected
to the Control Port. The Control Port is an open collector / open drain output. While most Parallel
Ports have internal pull-up resistors, there is a few which don't. Therefore, by incorporating the two
10K external pull up resistors, the circuit is more portable for a wider range of computers, some of
which may have no internal pull up resistors.
We make no effort to place the Data bus into reverse direction. Therefore, we hard wire the
R/W line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a
result, we cannot read back the LCD's internal Busy Flag which tells us if the LCD has accepted and
finished processing the last instruction. This problem is overcome by inserting known delays into our
program.
3
The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy here. As with all the
examples, I've left the power supply out. We can use a bench power supply set to 5v or use an onboard
+5 regulator. Remember a few de-coupling capacitors, especially if we have trouble with the circuit
working properly.
SETB RW
As we mentioned above, the EN line is used to tell the LCD that we are ready for it to execute
an instruction that we've prepared on the data bus and on the other control lines. Note that the EN line
must be raised/ lowered before/after each instruction sent to the LCD regardless of whether that
instruction is read or write text or instruction. In short, we must always manipulate EN when
communicating with the LCD. EN is the LCD's way of knowing that we are talking to it. If we don't
raise/lower EN, the LCD doesn't know we're talking to it on the other lines.
Thus, before we interact in any way with the LCD we will always bring the EN line low with
the following instruction:
CLR EN
And once we've finished setting up our instruction with the other control lines and data bus lines,
we'll always bring this line high:
SETB EN
The line must be left high for the amount of time required by the LCD as specified in its
datasheet. This is normally on the order of about 250 nanoseconds, but checks the datasheet. In the
case of a typical microcontroller running at 12 MHz, an instruction requires 1.08 microseconds to
execute so the EN line can be brought low the very next instruction. However, faster microcontrollers
(such as the DS89C420 which executes an instruction in 90 nanoseconds given an 11.0592 MHz
crystal) will require a number of NOPs to create a delay while EN is held high. The number of NOPs
that must be inserted depends on the microcontroller we are using and the crystal we have selected.
The instruction is executed by the LCD at the moment the EN line is brought low with a final
CLR EN instruction.
3
Checking the busy status of the LCD:
As previously mentioned, it takes a certain amount of time for each instruction to be executed
by the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator
input of the LCD as well as the instruction which is being executed.
While it is possible to write code that waits for a specific amount of time to allow the LCD to
execute instructions, this method of "waiting" is not very flexible. If the crystal frequency is changed,
the software will need to be modified. A more robust method of programming is to use the "Get LCD
Status" command to determine whether the LCD is still busy executing the last instruction received.
The "Get LCD Status" command will return to us two tidbits of information; the information
that is useful to us right now is found in DB7. In summary, when we issue the "Get LCD Status"
command the LCD will immediately raise DB7 if it's still busy executing a command or lower DB7 to
indicate that the LCD is no longer occupied. Thus, our program can query the LCD until DB7 goes
low, indicating the LCD is no longer busy. At that point we are free to continue and send the next
command.
4
CHAPTER 4
SOFTWARE DESCRIPTION
4
Next, connect to board to your computer with a USB cable. This will both power the board and
allow the IDE to send instructions to the board. You’ll need a data USB cable (a charge-only cable
will not work), with connectors that fit both the board and your computer.
The most common USB connector is USB-A, but newer laptop computers may only have USB-C.
To compile and upload sketches for your board Arduino IDE needs a collection of files for that
board called a board package.
When Arduino IDE detects a board with a missing board package, it may ask you to install the
missing files:
If no prompt appears, proceed with the next step. If you at any point need to manually find and
add a missing board package, see Add boards to Arduino IDE.
4
Using the board selector (requires IDE 2)
Using the Tools menu
If it is unknown, the “Select Other board and port” dialog will open. See Select board and
port in Arduino IDE for details.
If the board could be identified, but you are missing the board platform, you may be
asked to install it:
Select Yes to automatically install the board package in the background.
Select Install manually to view the package in the Board Manager.
To learn more about installing boards, see Add a board to Arduino IDE.
4
Using the Tools menu
Select board:
1. Click on Tools in the menu bar and find the Board row. If a board is currently selected
it will be displayed here.
2. Hover over the Board row to reveal the installed board packages. These packages
contain some popular boards:
SELECT PORTS:
1. Click on Tools in the menu bar and find the Port row. If a board is currently selected it will be
displayed here.
4
Fig 4.6 port selector page
2 Hover over the Port to reveal all ports. For Arduino devices, the board name
will typically be displayed after the port, for example:
COM3 (Arduino Uno)
/dev/cu.usbmodem14101 (Arduino Uno)
/dev/ttyACM0 (Arduino Uno)
3.Click on a port to select it. If the port with your board is already selected you don’t have to do
anything. If you don’t see your board in the list, see If your board does not appear in the port menu.
5. Upload a sketch
1. Write a sketch, or use an Example such as Blink (File > Examples > 01.Basics > Blink).
2. Optional: Click the Verify button to try compiling the sketch and check for errors.
3. Click the Upload button to program the board with the sketch.
Your sketch will start running on the board. It will run again each time the board is reset.
Troubleshooting
Make sure you’ve followed the steps before, especially selecting the board and
port correctly.
If you can’t find your board in the port menu, or if the Tools > Port port menu is missing,
see If your board does not appear in the port menu.
If you get an upload error, see Errors when uploading a sketch.
4
CHAPTER 5
ADVANTAGES AND DISADVANTAGES &APPLICATION’S
Advantages:
Disadvantages:
Applications:
4
CHAPTER 6
RESULTS
The project “Smart Road Safety and Vehicle Accident Prevention System for Mountain
Roads” was designed a vehicle accident prevention system for hill areas. The sensing of vehicle
arrival and departure is done using IR sensor and give the alert indication with LEDs. The project has
been implemented successfully and matched the expected results.
Initially no vehicle is detected in the figure LED indicates green on both sides.
The above figure in left side detected the vehicle therefore it indicates the right side red LED and left
side should pass first
4
The above figure in right side detected the vehicle therefore it indicates the left side red LED and
right side should pass first
4
CONCLUSION
In conclusion, the implementation of a smart road safety and accident prevention system for
mountain roads is essential to enhance safety for drivers and passengers. By incorporating real-time
monitoring, warning systems, automated response mechanisms, emergency communication, data
analysis, and fostering collaboration, such a system can effectively reduce accidents and improve
overall road safety in mountainous regions.
Integrating features of all the hardware components used have been developed in it. Presence
of every module has been reasoned out and placed carefully, thus contributing to the best working of
the unit. Secondly, using highly advanced IC’s with the help of growing technology, the project has
been successfully implemented. The project has been successfully designed and tested.
4
FUTURE SCOPE
The project can be extended using laser and LDR (Light Dependent resistor) which gives
better performance than IR sensors.
The project can be extended using solar energy, street lights and LDR for intensity control of
street lights.
5
REFERENCES
1. Jessen Joseph Leo., R. Monisha, et.al., Vehicle movement control and accident avoidance in
hilly track, IEEE Int. Conf. on Electronics and Communication Systems (ICECS).pp. 1-
5(2014).
Links:
a) https://nevonprojects.com/smart-road-safety-and-vehicle-accident-prevention-system-for-
mountain-roads/
5
APPENDIX
CODE:
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define ir1 8
#define ir2 9
#define r1 10
#define g1 11
#define r2 12
#define g2 13
void setup() {
// Initialize serial communication and pins
Serial.begin(9600);
pinMode(ir1, INPUT);
pinMode(ir2, INPUT);
pinMode(r1, OUTPUT);
pinMode(g1, OUTPUT);
pinMode(r2, OUTPUT);
pinMode(g2, OUTPUT);
digitalWrite(r1, LOW);
digitalWrite(g1, LOW);
digitalWrite(r2, LOW);
digitalWrite(g2, LOW);
// Initialize LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Welcome To The");
lcd.setCursor(0, 1);
lcd.print(" Project ");
delay(2000);
lcd.clear();
}
void loop() {
int i1 = digitalRead(ir1);
int i2 = digitalRead(ir2);
if (i1 == 0) {
digitalWrite(r1, HIGH); // Turn on red LED
digitalWrite(g1, LOW); // Turn off green LED
lcd.setCursor(0, 0);
lcd.print("Right Side: STOP");
} else {
digitalWrite(r1, LOW); // Turn off red LED
digitalWrite(g1, HIGH); // Turn on green LED
lcd.setCursor(0, 0);
lcd.print("Right Side: GO ");
5
}
// Check the status of the second IR sensor (right side)
if (i2 == 0) {
digitalWrite(r2, HIGH); // Turn on red LED
digitalWrite(g2, LOW); // Turn off green LED
lcd.setCursor(0, 1);
lcd.print("Left Side: STOP");
} else {
digitalWrite(r2, LOW); // Turn off red LED
digitalWrite(g2, HIGH); // Turn on green LED
lcd.setCursor(0, 1);
lcd.print("Left Side: GO ");
}
delay(100); // Small delay to stabilize readings
}