Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Fire Fighting Robot

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 40

Fire Fighting Robot

Introduction

Detecting fire and extinguishing is a hazardous job for a fire extinguisher, it


often risks the life of that person. This project aims in giving a technical
solution to the mentioned problem. A robot is a mechanical design that is
capable of carrying out a complex series of actions automatically, especially one
programmable by a computer. A fire extinguisher robot is an automatically
controlled robot that has a small fire extinguisher unit added on to it. We are
using the flame sensor detects the fire and gives the further signal to the
extinguisher units to trigger the pump and spray the water. The whole system is
programmed using an Arduino UNO board (ATmega328P microcontroller)
which forms the brain of the system.

Block Diagram
Circuit Diagram

Material List

1. Batteries (12V, 9V)


2. Battery Connectors
3. Toggle Switch
4. Diode
5. Capacitor
6. Resistor
7. LED
8. Voltage Regulator
9. Transistor
10.Photo Diode
11.IC LM358
12.Pre-set Resistor
13.Opto-isolators
14.Arduino
15.Motor Driver
16.UDM
17.Servo Motors
18.DC Motors
19.Tires
20.Relay
21.Water Pump
22.PCB
23.Soldering Wire
24.Ribbon Wire
25.Water pipe

Components Description

Resistors
The flow of charge (or current) through any material, encounters an opposing
force similar in many respect to mechanical friction. This opposing force is
called resistance of the material. It is measured in ohms. In some electric
circuits resistance is deliberately introduced in the form of the resistor.

Resistors are of following types:

1. Wire wound resistors.


2. Carbon resistors.
3. Metal film resistors.
Wire Wound Resistors:
Wire wound resistors are made from a long (usually Ni-Chromium) wound on a
ceramic core. Longer the length of the wire, higher is the resistance. So
depending on the value of resistor required in a circuit, the wire is cut and
wound on a ceramic core. This entire assembly is coated with a ceramic metal.
Such resistors are generally available in power of 2 watts to several hundred
watts and resistance values from 1ohm to 100k ohms. Thus wire wound
resistors are used for high currents.

Carbon Resistors:

Carbon resistors are divided into three types:

a. Carbon composition resistors are made by mixing carbon grains with binding
material (glue) and moduled in the form of rods. Wire leads are inserted at
the two ends.
b. After this an insulating material seals the resistor. Resistors are available in
power ratings of 1/10, 1/8, 1/4 , 1/2 , 1.2 watts and values from 1 ohm to 20
ohms.
c. Carbon film resistors are made by deposition carbon film on a ceramic rod.
They are cheaper than carbon composition resistors.
d. Cement film resistors are made of thin carbon coating fired onto a solid
ceramic substrate.
e. The main purpose is to have more precise resistance values and greater
stability with heat. They are made in a small square with leads.

Metal Film Resistors:


They are also called thin film resistors. They are made of a thin metal coating
deposited on a cylindrical insulating support. The high resistance values are not
precise in value; however, such resistors are free of inductance effect that is
common in wire wound resistors at high frequency.

Variable Resistors:

Potentiometer is a resistor where values can be set depending on the


requirement. Potentiometer is widely used in electronics systems. Examples are
volume control, tons control, brightness and contrast control of radio or T.V.
sets.

RESISTOR COLOR CODE

1st 2nd 3rd band 4th band Temp.


Color
band band (multiplier) (tolerance) Coefficient

Black 0 0 ×100

Brown 1 1 ×101 ±1% (F) 100 ppm


Red 2 2 ×102 ±2% (G) 50 ppm

Orange 3 3 ×103 15 ppm

Yellow 4 4 ×104 25 ppm

Green 5 5 ×105 ±0.5% (D)

Blue 6 6 ×106 ±0.25% (C)

Violet 7 7 ×107 ±0.1% (B)

Gray 8 8 ×108 ±0.05% (A)

White 9 9 ×109

Gold ×10−1 ±5% (J)

Silver ×10−2 ±10% (K)

None ±20% (M)

Example: 1k or 1000 ohms


Band1

Band 2

Band 3

Band 4

CAPACITORS

A capacitor can store charge, and its capacity to store charge is called
capacitance. Capacitors consist of two conducting plates, separated by an
insulating material (known as dielectric). The two plates are joined with two
leads. The dielectric could be air, mica, paper, ceramic, polyester, polystyrene,
etc. This dielectric gives name to the capacitor. Like paper capacitor, mica
capacitor etc.

Types of Capacitors:- Capacitors are of two Types Fixed and variable capacitor.

Fixed types of capacitor are further of two types:-

Polar Capacitor:- Those capacitor have polarity are known as polar capacitor.
Electrolytic capacitor are the example of polar capacitors.
Non Polar Capacitor:- Those capacitor have no polarity are known as NON-
polar capacitor. Ceramic capacitor are the example of non polar capacitors

Electrolytic Capacitor: Electrolytic capacitors have an electrolyte as a


dielectric. When such an electrolyte is charged, chemical changes takes place in
the electrolyte. If its one plate is charged positively, same plate must be charged
positively in future. We call such capacitors as polarized. Normally we see
electrolytic capacitor as polarized capacitors and the leads are marked with
positive or negative on the can. Non-electrolyte capacitors have dielectric
material such as paper, mica or ceramic. Therefore, depending upon the
dielectric, these capacitors are classified.
Ceramic Capacitor: Such capacitors have disc or hollow tabular shaped
dielectric made of ceramic material such as titanium dioxide and barium
titanate. Thin coating of silver compounds is deposited on both sides of
dielectric disc, which acts as capacitor plates. Leads are attached to each sides
of the dielectric disc and whole unit is encapsulated in a moisture proof
coating. Disc type capacitors have very high value up to 0.001uf. Their working
voltages range from 3V to 60000V. These capacitors have very low leakage
current. Breakdown voltage is very high.

Diode:-

Diodes are semiconductor devices which might be described as passing current


in one direction only. Diodes have two terminal, an anode and a cathode. The
cathode is always identified by a dot, ring or some other mark. Diode is a
unidirectional device. In this current flows in only one direction.
Diodes can be used as voltage regulators, tuning devices in rf tuned circuits,
frequency multiplying devices in rf circuits, mixing devices in rf circuits,
switching applications or can be used to make logic decisions in digital circuits.
There are also diodes which emit "light", of course these are known as light-
emitting-diodes or LED's.

a rectifying diode of the 1N4001-07 ( 1A) type or even one of the high power,
high current stud mounting types. You will notice the straight bar end has the
letter "k", this denotes the "cathode" while the "a" denotes anode. Current can
only flow from anode to cathode and not in the reverse direction, hence the
"arrow" appearance. This is one very important property of diodes.

The principal early application of diodes was in rectifying 50 / 60 Hz AC mains


to raw DC which was later smoothed by choke transformers and / or capacitors.
This procedure is still carried out today and a number of rectifying schemes for
diodes have evolved, half wave, full wave and bridge, full wave and bridge
rectifiers.
As examples in these applications the half wave rectifier passes only the
positive half of successive cycles to the output filter through D1. During the
negative part of the cycle D1 does not conduct and no current flows to the load.
In the full wave application it essentially is two half wave rectifiers combined
and because the transformer secondary is centre tapped, D1 conducts on the
positive half of the cycle while D2 conducts on the negative part of the cycle.
Both add together. This is more efficient. The full wave bridge rectifier operates
essentially the same as the full wave rectifier but does not require a cetre tapped
transformer. Further discussion may be seen on the topic power supplies

1N400X series Diode:-

Features

• Diffused Junction

• High Current Capability and Low Forward Voltage Drop

• Low Reverse Leakage Current

• Lead Free Finish


1N4148 Diode

The 1N4148 and 1N4448 are high-speed switching diodes fabricated in planar
technology, and encapsulated in hermetically sealed leaded glass SOD27 (DO-
35) packages.
FEATURES

• Hermetically sealed leaded glass SOD27 (DO-35) package

• High switching speed: max. 4 ns

• General application

• Continuous reverse voltage: max. 100 V

• Repetitive peak reverse voltage: max. 100 V

• Repetitive peak forward current: max. 450 mA.


APPLICATIONS

• High-speed switching

IC

IC (Integrated Circuit) means that all the components of the circuit are
fabricated on same chip. Digital ICs are a collection of resistors, diodes, and
transistors fabricated on a single piece of semiconductor, usually silicon called a
substrate, which is commonly referred to as ‘wafer’. The chip is enclosed in a
protective plastic or ceramic package from which pins extend out connecting
the IC to other device. Suffix N or P stands for dual-in-line (plastic package
(DIP) while suffix J or I stands for dual-in-lime ceramic package. Also the
suffix for W stands for flat ceramic package.

The pins are numbered counter clockwise when viewed from the top of the
package with respect to an identity notch or dot at one end of the chip.The
manufacturer’s name can usually be guessed from its logo that is printed on the
IC. The IC type number also indicates the manufacturer’s code. For e.g. DM
408 N SN 7404 indicates National Semiconductor and Texas Instruments.

Other examples are:

Fair Child : UA, UAF

National Semiconductor : DM, LM, LH, LF, and TA.

Motorola : MC, MFC.

Sprague : UKN, ULS, ULX.

Signetic : N/s, NE/SE, and SU.


Burr-Brown : BB.

Texas Instruments : SN.

The middle portion i.e. the IC type number tells about the IC function and also
the family, which the particular IC belongs to.IC’s that belongs to standard TTL
series have an identification number that starts with 74; for e.g. 7402, 74LS04,
74S04 etc. IC’s that belongs to standard CMOS family their number starts with
4, like 4000, 451B, 4724B, 1400. The 74C, 74HC, 74AC & 74ACT series are
newer CMOS series.

Various series with TTL logic family are:-

Standard TTL 74.

Schottky TTL 74s.

Low power Schottky 74LS.

Advance Schottky 74AS.

Advanced Low Power Schottky 74ALs.

Also there are various series with CMOS logic family as metal state CMOS 40
or 140.

Transistor:-

The schematic representation of a transistor is shown. Note the arrow pointing


down towards the emitter. This signifies it's an NPN transistor A transistor is
basically a current amplifier. Say we let 1mA flow into the base. We may get
100mA flowing into the collector. Note: The currents flowing into the base and
collector exit through the emitter (sum off all currents entering or leaving a
node must equal zero). The gain of the transistor will be listed in the datasheet
as either βDC or Hfe. The gain won't be identical even in transistors with the

same part number. The gain also varies with the collector current and
temperature.
LED:- LED means light emitting diode. Its function is similar to the diode. But
these are not made up from silicon or germanium. These are generally used as a
indicating device. There are variety of LEDs are available in market depending
upon their size and colour.

Polarity of LED:- LED have polarity. We can judge its polarity by watching
flags in its structure. Bigger flag is known as cathode and smaller flag is known
as anode as shown below.
Voltage Regulator The LM78XX 3-terminal positive voltage regulators
employ internal current-limiting, thermal shutdown and safe-area compensation,
making them essentially indestructible. Heat sinking is provided; they can
deliver over 1.0A output current. They are intended as fixed voltage regulators
in a wide range of applications including local (on-card) regulation for
elimination of noise and distribution problems associated with single-point
regulation. In addition to use as fixed voltage regulators.

Features

■ Output current up to 1 A

■ Output voltages of 5; 6; 8; 9; 12; 15; 18; 24 V


■ Thermal overload protection

■ Short circuit protection

DC MOTOR

PRINCIPLE OF OPERATION

In any electric motor, operation is based on simple electromagnetism. A


current-carrying conductor generates a magnetic field; when this is then placed
in an external magnetic field, it will experience a force proportional to the
current in the conductor, and to the strength of the external magnetic field. As
you are well aware of from playing with magnets as a kid, opposite (North and
South) polarities attract, while like polarities (North and North, South and
South) repel. The internal configuration of a DC motor is designed to harness
the magnetic interaction between a current-carrying conductor and an external
magnetic field to generate rotational motion.

Arduino

1 Introduction: An Arduino board with a RS-232 serial interface (upper left)


and an Atmel ATmega8 microcontroller chip (black, lower right). The 14 digital
I/O pins are located at the top and the 6 analog input pins at the lower right.
Arduino is an 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 slight simplifications and modifications,
and a Processing-based integrated development environment. The Arduino
project received an honorary mention in the Digital Communities category at
the 2006 Prix Ars Electronics.

4.2 HARDWARE:

Fig 4.1 Arduino 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. Some shields communicate
with the Arduino board directly over various pins, but many shields are
individually addressable via an I²C serial bus, allowing many shields to be
stacked and used in parallel. 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.

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 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, Duemilanove, and current Uno provide 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 may provide
male header pins on the underside of the board to be plugged into solderless
breadboards.

3 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 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

The integrated pin 13 LED

A typical first program for a microcontroller simply blinks an LED on and off.
In the Arduino environment, the user might write a program like this

It is a feature of most Arduino boards that they have an LED and load resistor
connected between pin 13 and ground, a convenient feature for many simple
tests.[29] 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. See Cyclic executive

The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs,
and uses avrdude to upload programs to the board.As the Arduino platform uses
Atmel microcontrollers Atmel’s development environment, AVR Studio or the
newer Atmel Studio, may also be used to develop
software for the Arduino. For educational purposes there is third party graphical
development environment called Minibloq available under a different open
source license.

4.4 Language Reference

Arduino programs can Variables Constants Functions Digital I/O


be divided in three main pinMode()
HIGH | LOW
parts: structure, values
digitalWrite()
(variables and INPUT | OUTPUT|
digitalRead()
constants), and INPUT_PULLUP
functions. Structure
true | false
setup() Analog I/O
integer constants
analogReference()
loop()
floating point constants
analogRead()
analogWrite() - PWM
Control Structures
Data Types
if
void Due only
if...else
boolean analogReadResolution()
for
char analogWriteResolution()
switch case
unsigned char
while
byte Advanced I/O
do... while
int tone()
break
unsigned int noTone()
continue word shiftOut()

return long shiftIn()

goto unsigned long pulseIn()

short

Further Syntax float Time

; (semicolon) double millis()

{} (curly braces) string - char array

// (single line comment) String - object

/* */ (multi-line array
comment)

#define

#include

Arithmetic Operators

= (assignment operator)

Arduino Overview:

The Arduino Uno is a microcontroller board based on the ATmega328


(datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a 16 MHz ceramic resonator, 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.

The Uno differs from all preceding boards in that it does not use the FTDI USB-
to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to
version R2) programmed as a USB-to-serial converter. Revision 2 of the Uno
board has a resistor pulling the 8U2 HWB line to ground, making it easier to put
into DFU mode. Revision 3 of the board has the following new features:

1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two
other new pins placed near to the RESET pin, the IOREF that allow the shields
to adapt to the voltage provided from the board. In future, shields will be
compatible both with the board that use the AVR,

which operate with 5V and with the Arduino Due that operate with 3.3V. The
second one is a not connected pin, that is reserved for future purposes.

Stronger RESET circuit.

Atmega 16U2 replace the 8U2.

"Uno" means one in Italian and is named to mark the upcoming release of
Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino,
moving forward. The Uno is the latest in a series of USB Arduino boards, and
the reference model for the Arduino platform; for a comparison with previous
versions, see the index of Arduino boards.

Summary: Microcontroller ATmega328

Operating Voltage 5V
Input Voltage (recommended) 7-12V

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 32 KB (ATmega328) of which 0.5


KB used by bootloader

SRAM 2 KB (ATmega328)

EEPROM 1 KB (ATmega328)

Clock Speed 16 MHz

Servo Motor
Tiny and lightweight with high output power. Servo can rotate approximately
180 degrees (90 in each direction), and works just like the standard kinds but
smaller. You can use any servo code, hardware or library to control these
servos. Good for beginners who want to make stuff move without building a
motor controller with feedback & gear box, especially since it will fit in small
places. It comes with a 3 horns (arms) and hardware.

Specifications
• Weight: 9 g
• Dimension: 22.2 x 11.8 x 31 mm approx.
• Stall torque: 1.8 kgf·cm
• Operating speed: 0.1 s/60 degree
• Operating voltage: 4.8 V (~5V)
• Dead band width: 10 μs
• Temperature range: 0 ºC – 55 ºC
Ultrasonic Modules
Ultrasonic module provides 2cm - 400cm non-contact measurement function,
these modules includes ultrasonic transmitters, receiver and control circuit. The
basic principle of work:
(1) Using IO trigger for at least 10us high level signal,
(2) The Module automatically sends eight 40 kHz and detect whether there is a
pulse signal back.
(3) IF the signal back, through high level, time of high output IO duration is the
time from sending ultrasonic to returning.
Test distance = (high level time × velocity of sound (340M/S) / 2,
Wire connecting direct as following:
 5V Supply
 Trigger Pulse Input
 Echo Pulse Output
 0V Ground

Photodiode

Definition: A special type of PN junction device that generates current when


exposed to light is known as Photodiode. It is also known as photodetector or
photosensor. It operates in reverse biased mode and converts light energy into
electrical energy.
The figure below shows the symbolic representation of a photodiode:

Principle of Photodiode

It works on the principle of Photoelectric effect.

The operating principle of the photodiode is such that when the junction of this
two-terminal semiconductor device is illuminated then the electric current starts
flowing through it. Only minority current flows through the device when the
certain reverse potential is applied to it.

ISOLATORS

Opto coupler (PC-817)

An isolator device to electrically insulate and isolate a separate component in a


circuit board arrangement to allow for relatively fast and convenient diagnostic
inspection of a circuit to locate failed components

In electronics, an opto-isolator, also called an optocoupler, photocoupler, or


optical isolator, is "an electronic device designed to transfer electrical signals by
utilizing light waves to provide coupling with electrical isolation between its
input and output. The main purpose of an opto-isolator is "to prevent high
voltages or rapidly changing voltages on one side of the circuit from damaging
components or distorting transmissions on the other side

An opto-isolator contains a source (emitter) of light, almost always a near


infrared light-emitting diode (LED), that converts electrical input signal into
light, a closed optical channel (also called dielectrical channel[5]), and a
photosensor, which detects incoming light and either generates electric energy
directly, or modulates electric current flowing from an external power supply.
The sensor can be a photoresistor, a photodiode, a phototransistor. Pin diagram
of PC 817 is shown below.
Working: - PC 817 is a 4 pin opto coupler as shown above. A series resistance
of 470 ohm is used to limit the voltage across the diode. +5V power supply is
connected to the first pin of IC, which is the anode pin diode. 2nd pin is
connected to the port of microcontroller. When the second pin is low then we
get low output, when the input to 2nd pin high we get high voltage the output.
Thus we isolate the voltage having the same logic level.

RELAYS

STRIP

OUT N/C

OUT N/O

SPRING

230V P

MAGNET

A relay is an electrically operated switch. The relay contacts can be made to


operate in the pre-arranged fashion. For instance, normally open contacts close
and normally closed contacts open. In electromagnetic relays, the contacts
however complex they might be, they have only two position i.e. OPEN and
CLOSED, whereas in case of electromagnetic switches, the contacts can have
multiple positions.
USE OF RELAY

The reason behind using relay for switching loads is to provide complete
electrical isolation. It means that there is no electrical connection between the
driving circuits and the driven circuits. The driving circuit may be low voltage
operated low power circuits that control several kilowatts of power. In our
circuit where a high fan could be switched on or off depending upon the output
from the telephone.

Since the relay circuit operated on a low voltage, the controlling circuit is quite
safe. In an electromagnetic relay the armature is pulled by a magnetic force
only. There is no electrical connection between the coil of a relay and the
switching contacts of the relay. If there are more than one contact they all are
electrically isolated from each other by mounting them on insulating plates and
washers. Hence they can be wired to control different circuits independently.

Some of the popular contacts forms are described below:

1. Electromagnetic relay

2. Power Relay.
3. Time Delay Relay.
4. Latching Relay.
5. Crystal Can Relay.
6. Co-axial Relay
1. Electromagnetic relay:

An electromagnetic relay in its simplest form consists of a coil, a DC current


passing through which produces a magnetic field. This magnetic field attracts an
armature, which in turn operates the contacts. Normally open contacts close and
normally closed contacts open. Electromagnetic relays are made in a large
variety of contacts forms.

2. Power relays:

Power relays are multi-pole heavy duty lapper type relays that are capable of
switching resistive loads of up to 25amp. These relays are widely used for a
variety of industrial application like control of fractional horse power motors,
solenoids, heating elements and so on. These relays usually have button like
silver alloy contacts and the contact welding due to heavy in rush current is
avoided by wiping action of the contacts to quench the arc during high voltage
DC switching thus avoiding the contact welding.

3. Time Delay Relay:

A time delay relay is the one in which there is a desired amount of time delay
between the application of the actuating signal and operation of the load
switching devices?

4. Latching Relay:
In a Latching Relay, the relay contacts remain in the last energized position
even after removal of signal in the relay control circuit. The contacts are held in
the last relay-energized position after removal of energisation either electrically
or magnetically. The contacts can be released to the normal position electrically
or mechanically.

INFRA RED SENSORS

Program

1. #include <Servo.h>
2. Servo Servo1, Servo2;
3. const int IR = A0;
4. const int Relay = A2;
5. const int Motor1 = 8;
6. const int Motor2 = 9;
7. const int Motor3 = 10;
8. const int Motor4 = 11;
9. const int TRIG_PIN = 3;
10.const int ECHO_PIN = 2;
11.int UDM_Data = 0;
12.void setup()
13.{
14.Serial.begin(9600);
15.Servo1.attach(5); //for UDM
16.Servo2.attach(4); //for Spray
17.pinMode(TRIG_PIN,OUTPUT);
18.pinMode(ECHO_PIN,INPUT);
19.pinMode(IR, INPUT);
20.pinMode(Relay, OUTPUT);
21.pinMode(Motor1, OUTPUT);
22.pinMode(Motor2, OUTPUT);
23.pinMode(Motor3, OUTPUT);
24.pinMode(Motor4, OUTPUT);
25.digitalWrite(Relay, HIGH);
26.digitalWrite(Motor1, HIGH);
27.digitalWrite(Motor2, LOW);
28.digitalWrite(Motor3, HIGH);
29.digitalWrite(Motor4, LOW);
30.Servo1.write(100); //UDM in center position
31.Servo2.write(180);
32.}
33.void loop()
34.{
35.Servo1.write(100); //UDM in center position
36.delay(1000);
37.UDM_Data = UDM();
38.Serial.println(UDM_Data);
39.if(UDM_Data < 30) //if distance is below 30CM stop and change
direction
40.{
41.digitalWrite(Motor1, LOW);
42.digitalWrite(Motor2, LOW);
43.digitalWrite(Motor3, LOW);
44.digitalWrite(Motor4, LOW);
45.delay(1000);
46.Servo1.write(40); //UDM Turn Left
47.delay(1000);
48.for(int i=0; i<5; i++)
49.{
50.UDM_Data = UDM();
51.delay(100);
52.}
53.if(UDM_Data < 30) //if distance is below 30CM then change direction
right
54.{
55.digitalWrite(Motor1, LOW);
56.digitalWrite(Motor2, HIGH);
57.digitalWrite(Motor3, HIGH);
58.digitalWrite(Motor4, LOW);
59.}
60.else //change the direction to the left
61.{
62.digitalWrite(Motor1, HIGH);
63.digitalWrite(Motor2, LOW);
64.digitalWrite(Motor3, LOW);
65.digitalWrite(Motor4, HIGH);
66.}
67.delay(3000);
68.digitalWrite(Motor1, LOW);
69.digitalWrite(Motor2, LOW);
70.digitalWrite(Motor3, LOW);
71.digitalWrite(Motor4, LOW);
72.delay(1000);
73.Servo1.write(100);
74.delay(1000);
75.digitalWrite(Motor1, HIGH);
76.digitalWrite(Motor2, LOW);
77.digitalWrite(Motor3, HIGH);
78.digitalWrite(Motor4, LOW);
79.}
80.if(digitalRead(IR) == 1)
81.{
82.digitalWrite(Motor1, LOW);
83.digitalWrite(Motor2, LOW);
84.digitalWrite(Motor3, LOW);
85.digitalWrite(Motor4, LOW);
86.delay(1000);
87.digitalWrite(Relay,LOW);
88.delay(100);
89.for(int j = 0; j<3; j++)
90.{
91.Servo2.write(120);
92.delay(1000);
93.Servo2.write(180);
94.delay(1000);
95.}
96.delay(1000);
97.digitalWrite(Motor1, HIGH);
98.digitalWrite(Motor2, LOW);
99.digitalWrite(Motor3, HIGH);
100. digitalWrite(Motor4, LOW);
101. }
102. }
103. int UDM()
104. {
105. long duration, distanceCm;
106. digitalWrite(TRIG_PIN, LOW);
107. delayMicroseconds(2);
108. digitalWrite(TRIG_PIN, HIGH);
109. delayMicroseconds(10);
110. digitalWrite(TRIG_PIN, LOW);
111. duration = pulseIn(ECHO_PIN,HIGH);
112. distanceCm = duration / 29.1 / 2 ;
113. return distanceCm;
114. }

Software Used

1. Arduino
2. Proteus

You might also like