Sie sind auf Seite 1von 47

Intelligent Ambulance Traffic Assistance and Centralized Accident

Alert System

Abstract
Traffic congestion and tidal flow management were recognized as major problems in
modern urban areas, which have caused much thwarting for the ambulance.
Moreover road accidents in the city have been incessant and to bar the loss of life due
to the accidents is even more crucial. To implement this we introduce a scheme
called AARS (Automatic ambulance rescue system). The main theme behind this
scheme is to provide a smooth flow for the ambulance to reach the hospitals in time and
thus minifying the expiration. The idea behind this scheme is to implement a ITS
which would control mechanically the traffic lights in the path of the ambulance. The
ambulance is controlled by the central unit which furnishes the most scant route to the
ambulance and also controls the traffic light according to the ambulance location and thus
reaching the hospital safely. The server also determines the location of the accident
spot through the sensor systems in the vehicle which encountered the accident and thus
the server walks through the ambulance to the spot. This scheme is fully automated,
thus it finds the accident spot, controls the traffic lights, helping to reach the hospital in
time.

In this project we build a city traffic model and demonstrate how ambulance can be
guided smoothly across densed city traffic. We also create a central sensor monitoring
system for accidents.











Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 1
Project Concept
The project has following main Units:
1) Microcontroller
2) Power Supply
3) Traffic Light Set
4) Ambulance Vehicle
5) Sample Vehicle to test Accident case
6) Sensors: a) IR, b) LDR


First We build a traffic junction with 4 pairs of traffic light sets with one green and one red
LED lights. These are controlled with a Transistor switch mechanism where transistor(NPN-
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

BC548) base is driven by Arduino's digital pin. Under normal situation, traffic light turns
green in every area in a rotation based system.

Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System



We create ambulance model with an IR remote preprogrammed and installed on the top of the
vehicle. There are 10 distinct switches and 10^10 possibilities are there. Hence technically it
is sufficient to accomodate in real time in all city ambulances.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


We installed IR receiver before and after the Traffic junction. The soon Ambulance comes in
proximity, traffic light in the section becomes green and remains green till it leaves the
junction and goes away from proximity of the receiver on the other side.
Accident Monitoring System
Our second module is accident monitoring system where we installed 4 LDR sensors across
four road junction. We create following special vehicle model.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


The vehicle has a Green LED on one side of the vehicle and a push switch at the front.
Whenever collision/accident occurs, it triggers the switch glowing the vehicle light.

Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System



Once the accident light is triggered, it triggers LDR even. Every area has a LDR sensor.
Hence MC can easily identify the area where accident has occurred.

Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System














Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 3
Microcontroller Unit

We use Arduino Dueminolova with ATMEG328 Microcontroller in our project. For entire
model to drive smoothly, the ground of power supply is made common with arduino
ground. Note that digital pins of Arduino produces about 4.2 v which is sufficient to drive
LEDs. However it does not produce enough current. Hence without external current, the
project runs a risk at draining microcontroller. Therefore alternative supply is used with it.

Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Arduino is a popular open-source single-board microcontroller, descendant of the open-
source Wiring platform, designed to make the process of using electronics in
multidisciplinary projects more accessible. The hardware consists of a simple open hardware
design for the Arduino board with an Atmel AVR processor and on-board input/output
support. The software consists of a standard programming language compiler and the boot
loader that runs on the board.
Arduino hardware is programmed using a Wiring-based language (syntax and libraries),
similar to C++ with some simplifications and modifications, and a Processing-based
integrated development environment.
Current versions can be purchased pre-assembled; hardware design information is available
for those who would like to assemble an Arduino by hand. Additionally, variations of the
Italian-made Arduinowith varying levels of compatibilityhave been released by third
parties; some of them are programmed using the Arduino software.
The Arduino project received an honorary mention in the Digital Communities category at
the 2006 Prix Ars Electronica.[

Hardware
An Arduino board consists of an 8-bit Atmel AVR microcontroller with complementary
components to facilitate programming and incorporation into other circuits. An important
aspect of the Arduino is the standard way that connectors are exposed, allowing the CPU
board to be connected to a variety of interchangeable add-on modules (known as shields).
Official Arduinos have used the megaAVR series of chips, specifically the ATmega8,
ATmega168, ATmega328, ATmega1280, and ATmega2560. A handful of other processors
have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a
16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs
such as the LilyPad run at 8 MHz and dispense with the onboard voltage regulator due to
specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a
boot loader that simplifies uploading of programs to the on-chip flash memory, compared
with other devices that typically need an external programmer.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

At a conceptual level, when using the Arduino software stack, all boards are programmed
over an RS-232 serial connection, but the way this is implemented varies by hardware
version. Serial Arduino boards contain a simple inverter circuit to convert between RS-232-
level and TTL-level signals. Current Arduino boards are programmed via USB, implemented
using USB-to-serial adapter chips such as the FTDI FT232. Some 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 ISP programming is used.)
The Arduino board exposes most of the microcontroller's I/O pins for use by other circuits.
The Diecimila, now superseded by the Duemilanove, for example, provides 14 digital I/O
pins, six of which can produce pulse-width modulated signals, and six analog inputs. These
pins are on the top of the board, via female 0.1 inch headers. Several plug-in application
"shields" are also commercially available.
The Arduino Nano, and Arduino-compatible Bare Bones Board and Boarduino boards
provide male header pins on the underside of the board to be plugged into solderless
breadboards.

Arduino Board Models
Arduin
o
Processor
Volt
age
Fla
sh
kB
EEPR
OM
kB
SR
AM
kB
Digi
tal
I/O
pins
...w
ith
PW
M
Ana
log
inp
ut
pins
USB
Interfa
ce
type
Dimen
sions
inches
Dimen
sions
mm
Diecimi
la
ATmega168 5 V 16 0.5 1 14 6 6 FTDI
2.7 in

2.1 in
68.6 m
m
53.3 m
m
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Due
[11]

ATMEL
SAM3U

25
6
0
[12]
50 54 16 16

Duemil
anove
ATmega168/328
P
5 V
16/
32
0.5/1 1/2 14 6 6 FTDI
2.7 in

2.1 in
68.6 m
m
53.3 m
m
Uno ATmega328P 5 V 32 1 2 14 6 6
ATmeg
a8U2
2.7 in

2.1 in
68.6 m
m
53.3 m
m
Leonard
o
Atmega32u4 5 V 32 1 2 14 6 12
Atmega
32u4
2.7 in

2.1 in
68.6 m
m
53.3 m
m
Mega ATmega1280 5 V
12
8
4 8 54 14 16 FTDI
4 in
2.1 in
101.6
mm
53.3 m
m
Mega25
60
ATmega2560 5 V
25
6
4 8 54 14 16
ATmeg
a8U2
4 in
2.1 in
101.6
mm
53.3 m
m
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Fio ATmega328P
3.3
V
32 1 2 14 6 8 None
1.6 in

1.1 in
40.6 m
m
27.9 m
m
Nano
ATmega168 or
ATmega328
5 V
16/
32
0.5/1 1/2 14 6 8 FTDI
1.70 in

0.73 in
43 mm

18 mm
LilyPad
ATmega168V or
ATmega328V
2.7-
5.5
V
16 0.5 1 14 6 6 None 2 in
50 mm


The board with marked color is used for this project.





Arduino Software


The Arduino IDE is a cross-platform application written in Java, and is derived from the IDE
for the Processing programming language and the Wiring project. It is designed to introduce
programming to artists and other newcomers unfamiliar with software development. It
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

includes a code editor with features such as syntax highlighting, brace matching, and
automatic indentation, and is also capable of compiling and uploading programs to the board
with a single click. There is typically no need to edit makefiles or run programs on a
command-line interface. Although building on command-line is possible if required with
some third-party tools such as Ino.
The Arduino IDE comes with a C/C++ library called "Wiring" (from the project of the same
name), which makes many common input/output operations much easier. Arduino programs
are written in C/C++, although users only need define two functions to make a runnable
program:
setup() a function run once at the start of a program that can initialize settings
loop() a function called repeatedly until the board powers off
A typical first program for a microcontroller simply blinks a LED on and off. In the Arduino
environment, the user might write a program like this:[14]
#define LED_PIN 13

void setup () {
pinMode (LED_PIN, OUTPUT); // enable pin 13 for digital output
}

void loop () {
digitalWrite (LED_PIN, HIGH); // turn on the LED
delay (1000); // wait one second (1000 milliseconds)
digitalWrite (LED_PIN, LOW); // turn off the LED
delay (1000); // wait one second
}
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

For the above code to work correctly, the positive side of the LED must be connected to pin
13 and the negative side of the LED must be connected to ground. The above code would not
be seen by a standard C++ compiler as a valid program, so when the user clicks the "Upload
to I/O board" button in the IDE, a copy of the code is written to a temporary file with an extra
include header at the top and a very simple main() function at the bottom, to make it a valid
C++ program.
The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs, and uses
avrdude to upload programs to the board.
For educational purposes there is third party graphical development environment called
Minibloq available under a different open source license.







Arduino Duemilanove
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


Overvi ew
The Arduino Duemilanove ("2009") is a microcontroller board based on
the ATmega168 or ATmega328. It has 14 digital input/output pins (of which 6 can be used as
PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack,
an ICSP header, and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-
DC adapter or battery to get started.
"Duemilanove" means 2009 in Italian and is named after the year of its release. The
Duemilanove is the latest in a series of USB Arduino boards; for a comparison with previous
versions.
Summary
Microcontroller ATmega168
Operating Voltage 5V
Input Voltage
(recommended)
7-12V
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory
16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB
used by bootloader
SRAM 1 KB (ATmega168) or 2 KB (ATmega328)
EEPROM 512 bytes (ATmega168) or 1 KB (ATmega328)
Clock Speed 16 MHz
Power
The Arduino Duemilanove can be powered via the USB connection or with an external power
supply. The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery.
The adapter can be connected by plugging a 2.1mm center-positive plug into the board's
power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the
POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be unstable. If using
more than 12V, the voltage regulator may overheat and damage the board. The recommended
range is 7 to 12 volts.
The power pins are as follows:
VIN. The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

supply voltage through this pin, or, if supplying voltage via the power jack, access it through
this pin.
5V. The regulated power supply used to power the microcontroller and other components on
the board. This can come either from VIN via an on-board regulator, or be supplied by USB
or another regulated 5V supply.
3V3. A 3.3 volt supply generated by the on-board FTDI chip. Maximum current draw is 50
mA.
GND. Ground pins.
Memory
The ATmega168 has 16 KB of flash memory for storing code (of which 2 KB is used for the
bootloader); the ATmega328has 32 KB, (also with 2 KB used for the bootloader).
The ATmega168 has 1 KB of SRAM and 512 bytes of EEPROM (which can be read and
written with the EEPROM library); the ATmega328 has 2 KB of SRAM and 1 KB of
EEPROM.
Input and Output
Each of the 14 digital pins on the Duemilanove can be used as an input or output,
using pinMode(), digitalWrite(), anddigitalRead() functions. They operate at 5 volts. Each pin
can provide or receive a maximum of 40 mA and has an internal pull-up resistor
(disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These
pins are connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value. See the attachInterrupt() function for
details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

The Duemilanove has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024
different values). By default they measure from ground to 5 volts, though is it possible to
change the upper end of their range using the AREF pin and the analogReference() function.
Additionally, some pins have specialized functionality:
I
2
C: analog input pins A4 (SDA) and A5 (SCL). Support I
2
C (TWI) communication using
the Wire library.
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button
to shields which block the one on the board.
See also the mapping between Arduino pins and ATmega168 ports.
Communi cati on
The Arduino Duemilanove has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega168 and ATmega328 provide UART
TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An
FTDI FT232RL on the board channels this serial communication over USB and the FTDI
drivers (included with the Arduino software) provide a virtual com port to software on the
computer. The Arduino software includes a serial monitor which allows simple textual data to
be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when
data is being transmitted via the FTDI chip and USB connection to the computer (but not for
serial communication on pins 0 and 1).
A SoftwareSerial library allows for serial communication on any of the Duemilanove's digital
pins.
The ATmega168 and ATmega328 also support I2C (TWI) and SPI communication. The
Arduino software includes a Wire library to simplify use of the I2C bus; see
the documentation for details. For SPI communication, use the SPI library.
Programmi ng
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

The Arduino Duemilanove can be programmed with the Arduino software (download). Select
"Arduino Diecimila or Duemilanove w/ ATmega168" or "Arduino Duemilanove
w/ ATmega328" from the Tools > Board menu (according to the microcontroller on your
board).
The ATmega168 or ATmega328 on the Arduino Duemilanove comes preburned with
a bootloader that allows you to upload new code to it without the use of an external hardware
programmer. It communicates using the original STK500protocol (reference, C header files).
You can also bypass the bootloader and program the microcontroller through the ICSP (In-
Circuit Serial Programming) header; see these instructions for details.
Automati c (Sof tware) Reset
Rather then requiring a physical press of the reset button before an upload, the Arduino
Duemilanove 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 FT232RL is
connected to the reset line of the ATmega168 or ATmega328 via a 100 nanofarad capacitor.
When this line is asserted (taken low), the reset line drops long enough to reset the chip. The
Arduino software uses this capability to allow you to upload code by simply pressing the
upload button in the Arduino environment. This means that the bootloader can have a shorter
timeout, as the lowering of DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the Duemilanove is connected to either 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 Duemilanove.
While it is programmed to ignore malformed data (i.e. anything besides an upload of new
code), it will intercept the first few bytes of data sent to the board after a connection is
opened. If a sketch running on the board receives one-time configuration or other data when
it first starts, make sure that the software with which it communicates waits a second after
opening the connection and before sending this data.
The Duemilanove contains a trace that can be cut to disable the auto-reset. The pads on either
side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may
also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset
line; see this forum thread for details.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

USB Overcurrent Protecti on
The Arduino Duemilanove has a resettable polyfuse that protects your computer's USB ports
from shorts and overcurrent. Although most computers provide their own internal protection,
the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB
port, the fuse will automatically break the connection until the short or overload is removed.
Physi cal Characteri sti cs
The maximum length and width of the Duemilanove PCB are 2.7 and 2.1 inches respectively,
with the USB connector and power jack extending beyond the former dimension. Three
screw holes allow the board to be attached to a surface or case. Note that the distance
between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of
the other pins.

Pin Configuration



Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 4
Power Supply Unit

1. Step down transformer
2. Voltage regulator
3. Capacitors
4. Diodes
Lets get into detail of rating of the devices :
Voltage regulator :
As we require a 5V we need LM7805 Voltage Regulator IC.
7805 IC Rating :
Input voltage range 7V- 35V
Current rating I
c =
1A
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Output voltage range V
Max=5.2V ,
V
Min=4.8V


LM7805 Pin Diagram
Transformer :
Selecting a suitable transformer is of great importance. The current rating and the secondary
voltage of the transformer is a crucial factor.
The current rating of the transformer depends upon the current required for the load to be
driven.
The input voltage to the 7805 IC should be at least 2V greater than the required 2V
output, therefore it requires an input voltage at least close to 7V.
So I chose a 6-0-6 transformer with current rating 500mA (Since 6*2 = 8.4V).
NOTE : Any transformer which supplies secondary peak voltage up to 35V can be used but as
the voltage increases size of the transformer and power dissipation across regulator increases.
Rectifying circuit :
The best is using a full wave rectifier
Its advantage is DC saturation is less as in both cycle diodes conduct.
Higher Transformer Utilization Factor (TUF).
1N4007 diodes are used as its is capable of withstanding a higher reverse voltage of
1000v whereas 1N4001 is 50V
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


Center Tap Full Wave Rectifier
Capacitors :
Knowledge of Ripple factor is essential while designing the values of capacitors
It is given by
Y=1/(43fRC) (as the capacitor filter is used)
1. f= frequency of AC ( 50 Hz)
2. R=resistance calculated
R= V/I
c

V= secondary voltage of transformer
V=62=8. 4
R=8.45/500mA=16.9 standard 18 chosen
3. C= filtering capacitance
We have to determine this capacitance for filtering
Y=V
ac-rms
/V
dc

V
ac-rms
= V
r
/23
V
dc=
V
Max
-(V
r
/2)
V
r=
V
Max-
V
Min

Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

V
r
= 5.2-4.8 =0. 4V
V
ac-rms = .3464V

V
dc = 5V

Y=0 .06928
Hence the capacitor value is found out by substituting the ripple factor in Y=1/(43fRC)
Thus, C= 2314 F and standard 2200F is chosen
Datasheet of 7805 prescribes to use a 0.01F capacitor at the output side to
avoid transient changes in the voltages due to changes in load and a 0.33F at the input side
of regulator to avoid ripples if the filtering is far away from regulator.
Circuit Diagram

5V Power Supply Circuit using 7805 Voltage Regulator





Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 5
Traffic Light Set

A traffic light set contains One Green LED and One Red LED Connected with Transsistors.
Anode of LED's are connected to +5v and grounds are connected to collector of their
respective transistors. Transistors emitter is grounded. Transistor is given base current
through a 100 ohm resistor from Digital PINs of Arduino
Following is the circuit diagram:
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


LED is connected with a resistor to limit the current.









Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 6
Arduino with LDR Light Sensor


Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System



The LDR is given power supply through a 1K resistor from board power out +5v VCC and
Ground pin. LDRs positive output is taken as input for reading the Light variation. The
program continuesly reads the value of pin 5 of the analog ports. Where there are no objects
in between, voltage across pin 5 is low, and when an object is placed, it is very high. Based
on this information product is counted.


CODE

void setup()
{
Serial.begin(19200);
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

}
void loop()
{
int a=analogRead(5);// assume LDR's output is connected to pin 5
Serial.println(a);
if(a<600)
{
Serial.println("Medium Light");
}
if(a<200)
{
Serial.println("High Light");
}
if(a>950)
{
Serial.println("Low Light");
}


}


Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 7
Arduino with IR Protocol
IR Communication Basics
IR radiation is simply light that we cannot see, which makes it great for communication. IR
sources are all around us. The sun, light bulbs, or any anything with heat is very bright in the IR
spectrum. When you use your TV remote, an IR LED is used to transmit information to your TV.
So, how does the IR receiver in your TV pick out signals from your remote among all of the
ambient IR? The answer is that the IR signal is modulated. Modulating a signal is like assigning a
pattern to your data, so that the receiver knows to listen.
A common modulation scheme for IR communication is something called 38kHz modulation.
There are very few natural sources that have the regularity of a 38kHz signal, so an IR
transmitter sending data at that frequency would stand out among the ambient IR. 38kHz
modulated IR data is the most common, but other frequencies can be used.
When you hit a key on your remote, the transmitting IR LED will blink very quickly for a fraction
of a second, transmitting encoded data to your appliance.

Each pulse is turned on and off at a frequency of 38kHz
If you were to hook an oscilloscope up to your TV remotes IR LED, you would see a signal similar
to the one above. This modulated signal is exactly what the receiving system sees. However, the
point of the receiving device is to demodulate the signal and output a binary waveform that can
be read by a microcontroller. When you read the OUT pin of the TSOP382 with the wave from
above, you will see something like this:
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


By controlling the spacing between the transmitted modulated signals, the waveform can be read
by an input pin on a microcontroller and decoded as a serial bit stream.
Below is conceptual view of how an IR transmitter receiver pair works.

Thanks to SBProjects.com for the gif and excellent IR resource!
An Arduino or other microcontroller can be connected to either end of the system to transmit
data (left side) or receive data (right side).
Hardware Setup
For the hardware in this tutorial, you will need these parts:
Arduino Uno
IR LED
TSOP382 IR Receiver
Mini Push Button Switch
330 Resistors
IR Keychain Remote or any IR remote that uses 38kHz modulation
You will be setting up two separate circuits both using an Arduino. The first example circuit uses
a TSOP382 IR photo sensor to receive and demodulate the IR signal from a common remote
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

control. The second example circuit uses an IR LED and current limiting resistor to transmit IR
codes to a common appliance, for example a home stereo or TV.
Here is the complete setup for connecting to an Arduino:

Hardware setup for both of the examples.
Be sure to connect your LED correctly! The long leg is positive and connects to the resistor, then
to the Arduinos output pin. The short leg is negative and is connected to ground (GND).
Also, you cannot see IR LED light with your eyes, since IR radiation is outside of the visible
spectrum. However, most cellphone cameras can detect short wave IR and can see the LED
faintly glowing.

When the LED is modulating at 38kHz, the LED should appear constantly lit, but dim.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Also, pay attention to the polarity of the TSOP382. Refer to the TSOP382 datasheet for the pinout
of the sensor.
The current limiting resistor attached to the LED can have values down to 100 (40mA) for full
power and longest range. If you use a larger value resistor, the LED wont light as bright and your
range will suffer. With a 330 resistor, you should be able to operate the IR LED across a dimly
lit room.
Receiving IR Example

In this example, all you need is the TSOP382 IR receiver connected to an Arduino and a
common remote control. The IR LED and button can stay connected, but you will not use it until
the next example.
IR remote controls are as ubiquitous as their appliance counterparts. What if you could put all of
those old remote controls to use in your next project? This example will show you how to read IR
remote codes from any IR remote using the TSOP382 IR photo sensor and an Arduino. Once you
can receive codes from individual button presses, your remote control and Arduino become a
general purpose, short range, communication interface!
The first thing you need to do is install the IR Arduino library. Instructions on how to install an
Arduino library can be found here.
IR Arduino Library
After downloading the IR library, go to your Arduino project directory -> libraries -> IRremote ->
examples -> IRrecvDemo -> and open the IRrecvDemo.ino. Upload the sketch to your Arduino.
The sketch will automatically decode the type of remote you are using and identify which button
on your remote is pressed. Open the serial port in the Arduino IDE at 9600 bps and hit different
buttons on your remote.
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System


Terminal window displaying random button presses on my remote. Different buttons show
different codes.
When specific buttons are pressed, you can use the incoming values to do something else in your
code, for example turn on and off a motor or LED.
The results from each button press can be found by calling the value() method:
Copy Code
results.value
You can print the values to the terminal window:
Copy Code
Serial.println(results.value, HEX); //prints the hex value a a button press
Or you might need read the values to run a conditional statement:
Copy Code
if(irrecv.decode(&results)) //this checks to see if a code has been received
{
if(results.value == 0xC284) //if the button press equals the hex value 0xC284
{
//do something useful here
}
irrecv.resume(); //receive the next value
}
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Transmitting IR Example

This example uses both the LED and TSOP382.
In this example, your Arduino and an IR LED imitate an IR remote to control an appliance (TV,
stereo, etc.). In order to control your appliance with the LED, you need to know what type of IR
protocol your appliance uses. The easiest way to find this out is to have the remote that comes
with the appliance.








Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

The following image explain the setup used in the project





Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 8
Circuit Diagram












Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 9
Coding
#include <Timer.h>
#include <IRremote.h>
int RECV_PIN = 9;//2
int RECV_PIN1 = 3;//1
int T=0;
int ambulance=-1;
IRrecv irrecv1(RECV_PIN1);
decode_results results;
int road_Segment=1;
int shouldDecode=0;
Timer t;
int GREEN_1=12;
int RED_1=11;

int GREEN_2=8;
int RED_2=10;

int GREEN_3=7;
int RED_3=6;

int GREEN_4=5;
int RED_4=4;
int ALL_GREEN[4];
int ALL_RED[4];
int TRAFF_IND=0;

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

for(int i=0;i<=13;i++)
pinMode(i, OUTPUT);

ALL_GREEN[0]=GREEN_1;
ALL_GREEN[1]=GREEN_2;
ALL_GREEN[2]=GREEN_3;
ALL_GREEN[3]=GREEN_4;

ALL_RED[0]=RED_1;
ALL_RED[1]=RED_2;
ALL_RED[2]=RED_3;
ALL_RED[3]=RED_4;

t.every(5000,SwitchLights,(void *)0 );
t.every(500,CheckLeave,(void *)0 );
Serial.begin(9600);

pinMode(3,INPUT);
pinMode(9,INPUT); // Start the receiver


SwitchLights((void*)0);
irrecv1.enableIRIn(); // Start the receiver
}


void CheckLeave(void * temp)
{
T++;
shouldDecode=5;
int TH=500;
int a=analogRead(5);
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

int b=analogRead(4);
int c=analogRead(3);
int d=analogRead(2);

if(a<TH)
{
Serial.println("ACCIDENT in 1");
}
if(b<TH)
{
Serial.println("ACCIDENT in 2");
}
if(c<TH)
{
Serial.println("ACCIDENT in 3");
}
if(d<TH)
{
Serial.println("ACCIDENT in 4");
}
}

void SwitchLights(void * temp)
{
shouldDecode=5;

if(ambulance==1)
{

return;
}
for(int i=0;i<4;i++)
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

{
if(i==TRAFF_IND)
{
digitalWrite(ALL_GREEN[i],HIGH);
}
else
{
digitalWrite(ALL_GREEN[i],LOW);
}
}

for(int i=0;i<4;i++)
{
if(i==TRAFF_IND)
{
digitalWrite(ALL_RED[i],LOW);
}
else
{
digitalWrite(ALL_RED[i],HIGH);
}
}
TRAFF_IND++;
if(TRAFF_IND>3)
{
TRAFF_IND=0;
}

}


void loop()
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

{
t.update();
if (irrecv1.decode(&results)&& shouldDecode<=-5)
{
if(ambulance<0)
{
Serial.println("AMB IN JNC");
shouldDecode=0;

Serial.println(results.value,HEX);
// Receive the next value
TRAFF_IND=3;
SwitchLights((void*)0);
ambulance=1;
}
delay(100);
irrecv1.resume();
T=0;
}

if(T>=8)
{
if(ambulance==1)
{
Serial.println("Ambulance Left");
ambulance=-1;
SwitchLights((void*)0);
}
T=0;

}
shouldDecode--;
Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

delay(10);
}




















Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 10
Results



















Intelligent Ambulance Traffic Assistance and Centralized Accident
Alert System

Chapter 11
Conclusion
Smart Traffic system is need of the hour to meet busy city traffic demands. Lot of research is
being carried out in the direction of density based traffic monitoring. Where as not much
work is being done towards priority based traffic management where different priority is
being given to different sets of vehicles.
In this project we demonstrate that a scalable real time traffic solution can be successfully
generated for ambulances. The system is also shown to be real time as it is tested with real
moving vehicles.
We also show sensor based accident alert system. This helps city authorities to monitor the
accidents and send ambulance urgently in that place. This unit is handfull in highway
accident monitoring and prevention system.

Das könnte Ihnen auch gefallen