Professional Documents
Culture Documents
USING IOT
A PROJECT REPORT
submitted by
R.RESHMA 820715106007
T.SHAFEERA BANU 820715106608
R.UMA MAHESWARI 820715106010
of
BACHELOR OF ENGINEERING
IN
ADUTHURAI
MARCH 2019
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
ii
CERTIFICATE OF EVALUATION
1. RESHMA.R AUTISM
Ms. G. DEEPIKA M.E.,
2. SHAFEERA BANU.T SPECTRUM
ASSISTANT PROFESSOR
3. UMA MAHESWARI.R DISORDER
MONITORING
USING IOT
iv
ABSTRACT
th autism severity but it is not specific forASD. There are a wide range of
havioral. However, promising new ideas and evidence are emerging from
for the onset and maintenance of Restricted and repetitive behaviors (RRBs).
This project consists of accelerometer sensor, tilt sensor, heart sensor, PIC
microcontroller, motor with help of driver relays and IoT module. The
accelerometer and tilt sensor are used to detect the child activity continuously.
The sensor values are fed to PIC (16F877A) microcontroller. If sensor values
crosses the threshold value, the vibration trigger the child and voice (music) will
be play while in autistic spectrum disorder. The IOT is used to monitor the child
activity continuously.
v
TABLE OF CONTENT
ABSTRACT V
LIST OF FIGURES IX
LIST OF TABLES X
LIST OF ABBREVIATIONS XI
1 INTRODUCTION 1
1.1INTRODUCTION TO IOT 2
2 LITERATURE SURVEY 4
3 SYSTEM ANALYSIS 8
3.1EXISTING SYSTEM 8
4.1BLOCK DIAGRAM 11
4.2CIRCUIT DIAGRAM 12
vi
5 SYSTEM DESCRIPTIONS 13
5.1HARDWARE REQUIREMENT 13
6 HARDWARE DESCRIPTION 14
6.1.2 ADVANTAGES 16
6.1.3 APPLICATION 17
6.2 SENSORS 17
6.2.4 APPLICATION 21
6.3.3 APPLICATION 24
6.6 RELAY 38
6.6.3 ADVANTAGES 42
6.7 VIBRATOR 43
6.7.2 USES 43
6.8.1 ADVANTAGES 44
7 SOFTWARE DESCRIPTIONS 45
7.1.1 CONDITIONS 45
8 CONCLUSION 47
REFERENCES 49
APPENDICES 53
viii
LIST OF FIGURES
METER SENSOR 20
BEAT SENSOR 24
SENSOR 26
ix
LIST OF TABLES
DEVICE 20
x
LIST OF ABBREVATIONS
ADXL ACCELEROMETER
IR INFRARED
VR VIRTUAL REALITY
xi
CHAPTER – 1
INTRODUCTION
1
skills, to children with ASD, and results suggest that children were able to
appropriately understand, use, and react to virtual environments with the
possibility of transferring theses skills to real life. In this paper, we are
monitoring patient through the IOT and data are stored in the cloud help oh ESP
8266 – 12E NODE MCU.
British entrepreneur Kevin Ashton coined the term in 1999 while working
at Auto-ID Labs (originally called Auto-ID centers, referring to a global
network of objects connected to radio, or RFID), Typically, IOT is expected to
offer advanced connectivity of devices, systems, and services that goes beyond
machine-to –machine(M2M) communication and covers a verity of protocols,
domains, and applications, The interconnection of these embedded device
(including smart objects), is expected to user in automation in nearly all field.
The microcontroller that has been used for this project is from PIC series.
PIC microcontroller is the first RISC based microcontroller fabricated in CMOS
(complementary metal oxide semiconductor) that uses separate bus for
instruction and data allowing simultaneous access of program and data memory.
The main advantage of CMOS and RISC combination is low power
consumption resulting in a very small chip size with a small pin count. The
main advantage of CMOS is that has immunity to noise than other fabrication
techniques.
3
CHAPTER - 2
LITERATURE SURVEY
2.2 Yung - Long Chu1, Shuping Chang et all proposed To Develop the
Mandarin-Phonetic-Symbol Communication Aid for High-Functioning
Autism Children – IEEE, 2014
In this existing study, a Mandarin-phonetic-symbol communication aid
named as shying communication board is developed for children with high-
functioning autism. The shying communication board can execute on Tablet PC
to assists autistic children to express their thought to other people. When an
4
autistic child wants to express his thought, he can press the corresponding
phonetic symbols by using the developed shying communication board. To
motivate the interesting of autistic children, the developed app provides a
picture-based testing for learning Mandarin phonetic symbols of variety objects.
Compared with the traditional paper keyboard, the developed aid could show
the typing phonetic symbol immediately on the screen, and provides the voice
of zhuy in pronunciation to improve autistic children’s language perception
skill.
5
real time, perform appropriate nonintrusive monitoring, and propose medical
and/or life style engagements, whenever needed and appropriate. The
framework, which relies on service-oriented architecture (SOA) and the Cloud,
allows a seamless integration of different technologies, applications, and
services. It also integrates mobile technologies to smoothly collect and
communicate vital data from a patient’s wearable biosensors while considering
the mobile devices’ limited capabilities and power drainage in addition to
intermittent network disconnections. Then, data are stored in the Cloud and
made available via SOA to allow easy access by physicians, paramedics, or any
other authorized entity. A case study has been developed to evaluate the
usability of the framework, and the preliminary results that have been analyzed
are showing very promising results.
6
2.6 S. M. Myers and C. P. Johnson, “Management of children with autism
spectrum disorders,” Pediatrics, vol. 120, pp. 1162–1182, 2007. IEEE
2016
We introduce AMP (Autism Management Platform), an integrated health
care information system for capturing, analyzing, and managing data associated
with the diagnosis and treatment of Autism Spectrum Disorder in children.
AMP's mobile application simplifies the means by which parents, guardians,
and clinicians can collect and share multimedia data with one another,
facilitating communication and reducing data redundancy, while simplifying
retrieval. Additionally, AMP provides an intelligent web interface and analytics
platform which allow physicians and specialists to aggregate and mine patient
data in real-time, as well as give relevant feedback to automatically learn data
filtering preferences over time. Together AMP's mobile app, web client, and
analytics engine implement a rich set of features that streamline the data
collection and analysis process in the context of a secure and easy-to-use system
so that data may be more effectively leveraged to guide treatment.
7
CHAPTER 3
SYSTEM DESIGN
The existing system is based on game world, it will cause addict to game
and healthy problem.
8
3.2 PROPOSED SYSTEM
9
ADVANTAGES OF PROPOSED SYSTEM
10
CHAPTER 4
11
4.2 CIRCUIT DAIGRAM
12
CHAPTER 5
SYSTEM DESCRIPTIONS
Tilt sensor
Accelerometer sensor
Heart beat sensor
Amplifier
LCD Display
Relay
Vibrator
ESP8266-12E IOT module
Voice board
Battery supply
13
CHAPTER 6
HARDWARE REQUIREMENTS
Battery Cells are the most basic individual component of a battery. They
consist of a container in which the electrolyte and the lead plates can interact.
Each lead-acid cell fluctuates in voltage from about 2.12 Volts when full to
about 1.75 volts when empty. Note the small voltage difference between a full
and an empty cell (another advantage of lead-acid batteries over rival
chemistries).
14
6.6.2 CHARACTERISTICS
Lead acid batteries were invented in 1859 by Gaston Planté and first
Figure 6.1 Lead acid battery
15
element makes them toxic and improper disposal can be hazardous to the
environment. The cell voltage is 2 Volts
DISCHARGE
During discharge, the lead dioxide (positive plate) and lead (negative plate)
react with the electrolyte of sulfuric acid to create lead sulfate, water and
energy.
CHARGE
During charging, the cycle is reversed: the lead sulfate and water are
electro-chemically converted to lead, lead oxide and sulfuric acid by an external
electrical charging source Many new competitive cell chemistries are being
developed to meet the requirements of the auto industry for EV and HEV
applications.
6.1.2 ADVANTAGES
Low cost.
Reliable.
Robust.
Tolerant to abuse.
Tolerant to overcharging.
Low internal impedance.
Can deliver very high currents.
Indefinite shelf life if stored without electrolyte.
Can be left on trickle or float charge for prolonged periods.
Wide range of sizes and capacities
The world's most recycled product
DISADVANTAGES
Very heavy and bulky.
Typical columbic charge efficiency only 70% but can be as high as 85%
to 90% for special designs.
16
Danger of overheating during charging
Not suitable for fast charging
Typical cycle life 300 to 500 cycles .
Must be stored in a charged state once the electrolyte has been introduced
to avoid deterioration of the active chemicals.
6.1.3 APPLICATION
Automotive and traction applications.
Standby/Back-up/Emergency power for electrical installations.
Submarines
UPS (Uninterruptible Power Supplies)
Lighting
High current drain applications.
Sealed battery types available for use in portable equipment.
6.2 SENSORS
Sensors are sophisticated devices tha are frequently used to detect and
respond to electrical or optical signals. A sensor converts the physical parameter
( for example: temperature, blood pressure, humidity, speed ,etc,) into a signal
which can be measured electrically.
6.2.1 ACCELEROMETER SENSOR
Breakout board for the 3 axis ADXL335 from Analog Devices. This is
the latest in a long, proven line of analog sensors - The ADXL335 is a triple
17
axis MEMS accelerometer with extremely low noise and power consumption -
only 320uA. The sensor has a full sensing range of +/-3g.Board comes fully
assembled and tested with external components installed. The included 0.1uF
capacitors set the bandwidth of each axis to 50Hz. and onboard regulator
3.3volts.
18
Accelerometers are useful for sensing vibrations in systems or for orientation
applications.
PIEZOELECTRIC
Piezoelectric sensing of acceleration is natural, as acceleration is directly
proportional to force. When certain types of crystal are compressed, charges of
opposite polarity accumulate on opposite sides of the crystal. This is known as
the piezoelectric effect. In a piezoelectric accelerometer, charge accumulates on
the crystal and is translated and amplified into either an output current or
voltage. Piezoelectric accelerometers only respond to AC phenomenon such as
vibration or shock. They have a wide dynamic range, but can be expensive
depending on their quality (Dasher 2005e)
19
Verplaetse has outlined the bandwidths associated with various
implementations of accelerometers as an input device. These are:
20
6.2.3 PRINCIPLES OF OPERATION
Most accelerometers are Micro-Electro-Mechanical Sensors (MEMS).
The basic principle of operation behind the MEMS accelerometer is the
displacement of a small proof mass etched into the silica
on surface of the integrated circuit and suspended by small beams. Consistent
with Newton's second law of motion (F = ma), as an acceleration is applied to
the device, a force develops which displaces the mass. A the support beams act
as a spring, and the fluid (usually air) trapped inside the IC acts as a damper,
resulting in a second order lumped physical system. This is the source of the
limited operational bandwidth and non-uniform frequency response of
accelerometers. For more information, see reference to Elwenspoek, 1993.
6.2.4 APPLICATIONS
Accelerometers can be used to measure vehicle acceleration.
Accelerometers can be used to measure vibration on cars, machines,
buildings, process control systems and safety installations. They can also be
used to measure seismic activity, inclination, machine vibration, dynamic
distance and speed with or without the influence of gravity. Applications for
accelerometers that measure gravity, wherein an accelerometer is specifically
configured for use in gravimetric, are called gravimeters.
Notebook computers equipped with accelerometers can contribute to
the Quake-Catcher Network (QCN), a BOINC project aimed at scientific
research of earthquakes.
MEDICAL APPLICATIONS
Zoll's AED Plus uses CPR-D•padz which contain an accelerometer to
measure the depth of CPR chest compressions.Within the last several years,
several companies have produced and marketed sports watches for runners that
21
include footpods, containing accelerometers to help determine the speed and
distance for the runner wearing the unit.
In Belgium, accelerometer-based step counters are promoted by the
government to encourage people to walk a few thousand steps each day.Herman
Digital Trainer uses accelerometers to measure strike force in physical training. [
It has been suggested to build football helmets with accelerometers in
order to measure the impact of head collisions.
NAVIGATION
22
They instruments have become gradually more popular and are being
adapted for increasing numbers of high end application. For example, the sensor
provides valuable information about both the vertical and horizontal inclination
of an airplane, which helps the pilot to understand how to tackle obstacles
during the flight. By knowing the current orientation of the plane, and the angle
at which the plane is inclined to the earth’s surface, stunt pilots, that is the Red
Arrows, can put on a fascinating air show. Tile sensor are essential decision-
making tool for the pilots.
23
6.3.3 APPLICATIONS
To monitor the angle at which a mobile phone or tablet is held for the
auto-rotate function
To detect the position of hand-hald game systems and in game controllers
To indicate the roll of boats, vehicles and aircraft
To estimate the height of a tree or building
To provide a warning system for the surface tilt angle of cryogenic
liquids during transportation
To monitor laser levels and seismic activity
24
This is a non-invasive measurement for changes in finger blood flow
during wakefulness and sleep. Pulse wave amplitude (PWA) is the most
frequently used parameter obtained by finger plethysmography. PWA is directly
and positively correlated to finger blood flow. The hypothesis of this study was
that finger plethysmography detects pharmacologically induced changes in
finger blood flow, in particular changes induced by stimulation and blockade of
vascular a-receptors.
25
6.4.1 WORKING OF HEART BEAT SENSOR
The operation of the board is very simple. After powering the board from
a 3-5.5V supply, the Enable (EN) pin must be pulled high to activate the IR
sensor. Next, place the tip of your forefinger gently over the sensor on its face.
Your finger should be still and should not press too hard on the sensor. Within a
couple seconds the circuit stabilizes and you will see the LED flashing
synchronously with your heart beat.
You can feed the output signal (V out) to either a digital I/O or an ADC
input pin of the microcontroller for measurement of the heart beat rate in BPM.
The output voltage waveform can also be viewed on an oscilloscope. I
connected Digilent’s Analog Discovery tool to check the input PPG and the
output waveforms from the two LPF stages. The following pictures show these
signal waveforms as displayed on the pc scrren. In our HBT sensor circuit is
coverd with Heat Shrink Sleeve to avoid noise.
26
6.4.2 APPLICATION
15 Memories.
PICs are popular with both industrial developers and hobbyists alike due
to their low cost, wide availability, large user base, extensive collection of
application notes, availability of low cost or free development tools, and serial
programming (and re-programming with flash memory) capability. Microchip
announced on February 2008 the shipment of its six billionth PIC processor.
A serial I/O port to allow data to flow between the controller and other
devices such as a PIC or another microcontroller.
Microcontrollers are:
Smaller in size
Inexpensive
The heart of the microcontroller is the CPU core. In the past, this has
traditionally been based on an 8 bit microprocessor unit. For example, Motorola
uses a basic 6800 microprocessor core their 6805/6808 microcontroller devices.
In the recent years, microcontrollers have been developed around specifically
designed CPU cores, for example the microchip PIC range of microcontrollers.
28
6.5.1 PIC 16877A:
CORE FEATURES
All single cycle instructions except for program branches which are two
cycle
29
Power – Up Timer (PWRT) and Oscillator Start – Up Timer (OST)
Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable
operation
Low-power consumption:
30
PERIPHERAL FEATURE :
Synchronous Serial Port (SSP) with SPI (Master mode) and 12C (Master/
Slave)
31
PIN DESCRIPTION
32
ARCHITECTURE OF PIC 16F877
33
The basic building block of PIC 16F877A is based on Harvard
architecture. The memory of a PIC 16F877A is divided into 3 sections. They
are:
Program memory
Data Memory
Data EEPROM
PROGRAM MEMORY
DATA MEMORY
The data memory is partitioned into multiple banks which contain the
General Purpose Registers and the Special Function Registers. Bits RP1 and
RP0 are the bank select bits.
The lower locations of each bank are reserved for the Special Function
Registers. Above the Special Function Registers are General Purpose Registers,
implemented as static RAM. All implemented banks contain Special Function
Registers.
DATA EEPROM
The data EEPROM and flash program memory is readable and writing
during normal operation. This memory is not directly mapped in the register file
space. Instead, it is indirectly addressed through the special function registers.
The EEPROM data memory allows single-byte reads and writes. The
flash memory allows single-word reads and four-word block writes.
34
REGISTERS:
Control Register
Status Register
Serial Receive/Transmit Buffer Register
Shift Register
CR and SR are the control and status registers used in operation. The CS
register is readable and writable. The lower six bits of the SR are read only. The
upper two bits of SR are read/write. SSPSR is the shift register used for shifting
data in or out.
SSPBUF is the buffer register to which data bytes are written to or read
form. In receive operations: SSPSR and SSPBUF together create a double-
buffered receiver. During transmission, the SSPBUF is not double-buffered.
TIMER MODULES:
Timer0 module
Timer1 module
Timer2 module
35
MSSP MODULE:
CONTROL REGISTERS
The MSSP module has three associated registers. These include a status
register (SSPSTAT) and two control registers (SSPCON and SSPCON2). The
use of these registers and their individual configuration bits differ significantly,
depending on whether the MSSP module is operated in SPI or I2C mode.
The Analog-to-Digital Converter module has five inputs for the 28-pi
devices and eight for the 40/44 pin devices. The conversion of an analog input
signal results in a corresponding 10-bit digital number.
The A/D module has high and low voltage reference input that is software
selectable to some combination of VDD, VSS, RA2 or RA3. The A/D converter
36
has a unique feature of being able to operate while the device is in sleep mode.
To operate in sleep mode, the A/D clock must be derived from the A/D internal
RC oscillator.
CORE ARCHITECTURE
Separate code and data spaces (Harvard architecture) for devices other
than PIC32, which has a Von Neumann architecture.
A small number of fixed length instructions
Most instructions are single cycle execution (2 clock cycles), with one
delay cycle on branches and skips
One accumulator (W0), the use of which (as source operand) is implied
(i.e. is not encoded in the opcode)
All RAM locations function as registers as both source and/or destination
of math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256 bytes),
extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and writable (this
is used to implement indirect jumps).
There is no distinction between memory space and register space because the
RAM serves the job of both memory and registers, and the RAM is usually just
referred to as the register file or simply as the register.
37
WORD SIZE
The word size of PICs can be a source of confusion. All PICs handle (and
address) data in 8-bit chunks, so they should be called 8-bit microcontrollers.
However, the unit of addressability of the code space is not generally the same
as the data space.
For example, PICs in the baseline and mid-range families have program
memory addressable in the same wordsize as the instruction width, i.e. 12 or 14
bits respectively. In contrast, in the PIC18 series, the program memory is
addressed in 8-bit increments (bytes), which differs from the instruction width
of 16 bits.
6.6 RELAY
A relay is an electrically operated switch. Current flowing through the
coil of the relay creates a magnetic field which attracts a lever and changes the
switch contacts. The coil current can be on or off so relays have two switch
positions and most have double throw (changeover) switch contacts as shown
in the diagram.
Relays allow one circuit to switch a second circuit which can be
completely separate from the first. For example a low voltage battery circuit can
use a relay to switch a 230V AC mains circuit. There is no electrical connection
inside the relay between the two circuits, the link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is
usually used to amplify the small IC current to the larger value required for the
38
relay coil. The maximum output current for the popular 555 timer IC is 200mA
so these devices can supply relay coils directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of
switch contacts, for example relays with 4 sets of changeover contacts are
readily available.
The coil will be obvious and it may be connected either way round. Relay
coils produce brief high voltage 'spikes' when they are switched off and this can
destroy transistors and ICs in the circuit. To prevent damage you must connect a
protection diode across the relay coil.
If you are choosing a relay for an existing PCB you will need to ensure
that its dimensions and pin arrangement are suitable. You should find this
information in the supplier's catalogue.
2. Coil voltage
The relay's coil voltage rating and resistance must suit the circuit
powering the relay coil. Many relays have a coil rated for a 12V supply but 5V
and 24V relays are also readily available. Some relays operate perfectly well
with a supply voltage which is a little lower than their rated value.
3. Coil resistance
The circuit must be able to supply the current required by the relay
coil. You can use Ohm's law to calculate the current:
supply voltage
Relay coil current =
coil resistance
40
4.Switch ratings(voltage and current)
The relay's switch contacts must be suitable for the circuit they are to
control. You will need to check the voltage and current ratings. Switch contact
arrangement(SPDT,DPDT etc)
Transistors and ICs must be protected from the brief high voltage
produced when a relay coil is switched off. The diagram shows how a signal
diode (eg 1N4148) is connected 'backwards' across the relay coil to provide this
protection. Current flowing through a relay coil creates a magnetic field which
collapses suddenly when the current is switched off. The sudden collapse of the
magnetic field induces a brief high voltage across the relay coil which is very
likely to damage transistors and ICs. The protection diode allows the induced
voltage to drive a brief current through the coil (and diode) so the magnetic fie
41
RELAY AND TRANSISTOR COMPARED
Relays can switch AC and DC, transistors can only switch DC.
Relays can switch higher voltages than standard transistors.
Relays are often a better choice for switching large currents (> 5A).
Relays can switch many contacts at once.
42
6.7 VIBRATOR
When mobile phones and pagers vibrate, the vibrating alert is produced
by a small component that is built into the phone or pager. Many older, non-
electronic buzzers and doorbells contain a component that vibrates for the
purpose of producing a sound. Tattoo machines and some types of electric
engraving tools contain a mechanism that vibrates a needle or cutting tool.
6.7.2 USES
43
Vibrating screens are used to separate bulk materials in a mixture of
different sized particles. For example, sand, gravel, river rock and crushed rock,
and other aggregates are often separated by size using vibrating screens.
This tiny DC motor has a shaft with an offset mass that vibrates when
it rotates. Motors like this are commonly found in cell phones and other devices
that use vibration for tactile feedback. The motor has 1.5″ leads and is encased
in a removable rubber sleeve that gives it flat surfaces for mounting and
prevents it
6.8.1 ADVANTAGES
44
CHAPTER 7
SOFTWARE DESCRIPTION
7.1 INTRODUCTION
7.1.1 CONDITIONS
HI-TECH Compiler.
45
MPLAB X is the latest version of the MPLAB IDE built by Microchip
Technology, and is based on the open-source Net Beans platform.
MPLAB X supports editing, debugging and programming of Microchip
8-bit, 16-bit and 32-bit PIC microcontrollers.
MPLAB 8.X is the last version of the legacy MPLAB IDE technology,
custom built by Microchip Technology in Microsoft Visual C++.
MPLAB supports project management, editing, debugging and
programming of Microchip 8-bit, 16-bit and 32-bit PIC microcontrollers.
MPLAB only works on Microsoft Windows. MPLAB is still available
from Microchip's archives, but is not recommended for new projects.
46
CHAPTER 8
CONCLUSION
Additionally, more participants are needed in the future for the user
study to assess the practical value of the system for children with ASD. In order
to explore the influence of the system on the communication ability of the
47
participants, we plan to continue with the analysis of the participants’
conversations in terms of the game-oriented content and the social content and
perform a statistical analysis of the change in the content of the conversation.
48
REFERENCES
[5] Y. Cai, N.K.H. Chia, D. Thalmann, N.K.N Kee, J. Zheng, N.M. Thalmann,
“Design and Development of a Virtual Dolphinarium for Children With
Autism,” IEEE Trans. on Neural Systems and Rehabilitation Engineering, Vol.
21 , No. 2, pp. 208-217, 2013.
49
syndrome (AS) and high functioning autism (HFA),” J. Autism Developmental
Disorders, vol. 38, pp. 581–591, 2008.
[8] E. W. Carter et al., “Promoting social competence and peer relationships for
adolescents with autism spectrum disorders,” Remedial Special Educ., vol. 35,
pp. 91–101, 2013.
50
[16] F. Ke and T. Im, “Virtual-reality-based social interaction training for
children with high-functioning autism,” J. Educ. Res., vol. 106, pp. 441–461,
2013.
51
[24] B. O. Ploog, A. Scharf, D. Nelson, and P. J. Brooks, “Use of
computerasisted technologies (CAT) to enhance social, communicative, and
language development in children with autism spectrum disorders,” J. Autism
Developmental Disorders, vol. 43, pp. 301–322, 2013.
52
APPENDICES
Program
#include<pic.h>
__CONFIG(0X3f72);
#define rs RD1
#define rw RD2
#define en RD3
#define sw RB0
int CNT,COUNT,COUNT1,val22,val33,val44,val55,VAL8;
int i,j,m,v,q=1,p=1,r,s;
int x;
int a,b,c,d,e,f,g;
int temp1,a1,b1,c1,d1,e1,f1,g1;
53
unsigned int temp,temp4,a4,b4,c4,d4,e4,f4,g4;
int temp3,a3,b3,c3,d3,e3,f3,g3;
{while(x--);
PORTD=com&0xf0;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
temp=com<<4;
PORTD=temp&0xf0;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}void init()
54
{lcd_command(0x02);
lcd_command(0x2c);
lcd_command(0x06);
lcd_command(0x0c);
lcd_command(0x01);
lcd_command(0x80);
PORTD=data&0xf0;
en=1;
rs=1;
rw=0;
delay(100);
en=0;
val1=data<<4;
PORTD=val1&0xf0;
en=1;
rs=1;
rw=0;
delay(100);
55
en=0;
{for(i=0;m[i]!=0;i++)
{lcd_data(m[i]);
}}
/*void delay1()
{ for(int i=0;i<20;i++)
{ T0CS=0;
T0SE=0;
PSA=0;
PS0=1;
PS1=1;
TMR0=60;
while(T0IF==0);
T0IF=0;
TMR0=0;
}*/
void sen1()
{CHS2=0;
CHS1=0;
56
CHS0=0;
ADON=1;delay(100);
ADCON0=(ADCON0|0x04);
delay(200);
temp0=ADRESH<<8;
delay(200);
temp0=temp0+ADRESL;
a0=temp0/100;
b0=temp0%100;
c0=b0/10;
d0=b0%10;
lcd_command(0x80);
lcd_display("X");
delay(1000);
lcd_command(0x81);
delay(1000);
lcd_data(a0+0x30);
delay(1000);
lcd_data(c0+0x30);
delay(1000);
57
lcd_data(d0+0x30);
delay(1000);
TXREG='X';
delay(1000);
//TXREG=(a+0x30);
//delay(100);
TXREG=(a0+0x30);
delay(100);
TXREG=(c0+0x30);
delay(100);
TXREG=(d0+0x30);
delay(100);
delay(1000);
}void sen2()
{CHS2=0;
CHS1=0;
CHS0=1;
ADON=1;delay(100);
ADCON0=(ADCON0|0x04);
delay(200);
58
temp1=ADRESH<<8;
delay(200);
temp1=temp1+ADRESL;
a1=temp1/100;
b1=temp1%100;
c1=b1/10;
d1=b1%10;
lcd_command(0x84);
lcd_display("Y");
lcd_command(0x85);
delay(1000);
lcd_data(a1+0x30);
delay(1000);
lcd_data(c1+0x30);
delay(1000);
lcd_data(d1+0x30);
delay(1000);
TXREG='Y';
delay(1000);
//TXREG=(a+0x30);
59
//delay(100);
TXREG=(a1+0x30);
delay(1000);
TXREG=(c1+0x30);
delay(1000);
TXREG=(d1+0x30);
delay(1000);
}void sen4()
{CHS2=0;
CHS1=1;
ADON=1;delay(100);
ADCON0=(ADCON0|0x04);
delay(100);
temp4=ADRESH<<8;
delay(100);
temp4=temp4+ADRESL;
a4=temp4/100;
b4=temp4%100;
c4=b4/10;
d4=b4%10;
60
lcd_command(0x88);
delay(100);
lcd_display("Z");
lcd_command(0x89);
lcd_data(a4+0x30);
lcd_data(c4+0x30);
lcd_data(d4+0x30);
TXREG='Z';
delay(1000);
//TXREG=(a+0x30);
//delay(100);
TXREG=(a4+0x30);
delay(1000);
TXREG=(c4+0x30);
delay(1000);
TXREG=(d4+0x30);
delay(1000);
}void heart_beat()
{while(CNT<=6)
{TMR1ON=1;
61
TMR1CS=0; // TIMER MODE
T1CKPS0=1;
TMR1H=0x0B;
TMR1L=0xDB;
while(TMR1IF==0)
{if((RB0==1)&&(VAL8==0))
{VAL8=1;
RB0==0;
COUNT=COUNT+1;
delay(10000);
}if(RB0==0)
{VAL8=0;
}}if(TMR1IF==1)
{TMR1IF=0;
CNT=CNT+1;
TMR1ON=0;
}COUNT1=COUNT;
CNT=0;
if(COUNT<6)
62
{COUNT1=COUNT1*14;
}if(COUNT>6)
{COUNT1=COUNT1*10;
}/*if(COUNT<6)
{COUNT1=COUNT1*14;
}if(COUNT>6)
{COUNT1=COUNT1*10;
}*/if(COUNT==0)
{COUNT1=0;
} val22=COUNT1%10;//UNIT DIGIT
val33=COUNT1/10;
val55=val33/10;
// hundred digit
//lcd_command(0x01);
delay(600);
lcd_command(0x8C);
lcd_display("HB");
lcd_command(0x8E);
lcd_data(val44+0x30);
63
lcd_data(val22+0x30);delay(50000);delay(50000);
COUNT=0;
TXREG='H';
delay(100);
TXREG=(val44+0X30);
delay(600);
TXREG=(val22+0X30);
delay(600);
if(COUNT1>0)
{if((COUNT1<90)&&(COUNT1>50))
{lcd_command(0xC0);
//delay(50000);delay(50000);delay(50000);
}if(COUNT1<40)
{buzzer=1;
lcd_command(0xC0);
delay(10000);
//delay(50000);delay(50000);delay(50000);
buzzer=0;
64
}}
void main()
{TRISB=0xf1;
TRISD=0x00;
TRISA=0x07;
PORTB=0x02;
TRISC=0x00;
PORTC=0x00;
ADCON1=0x80;
ADCON0=0x40;
RCSTA=0X90;
TXSTA=0x24;
SPBRG=25;
init();
lcd_command(0x80);
delay(5000);
lcd_display("welcome");
delay(50000);
lcd_command(0x01);
delay(5000);
65
while(1)
{SPEAKER=0;
delay(1000);
delay(1000);
sen4();
delay(1000);
heart_beat();
lcd_command(0xCC);
lcd_display("T");
lcd_command(0xCD);
lcd_data(til+0x30);
TXREG='T';
delay(100);
TXREG=(til+0x30);
//sen3();
//delay(1000);
//TXREG=13;
if((temp0>360)&&(p==1))
{p=0;
g=1;
66
//r=0;
v=v+1;
lcd_command(0xCF);
delay(5000);
lcd_data(v+0x30);
delay(50000);delay(50000);
}if((temp0<330)&&(g==1))
{g=0;
p=1;
}if(v>4)
{relay=1;
lcd_command(0x01);
lcd_command(0x80);
SPEAKER=1;
vib=1;
delay(50000);
delay(50000);
delay(50000);
delay(50000);
67
//SPEAKER=1;
delay(50000);
delay(50000);
delay(50000);
SPEAKER=0;
v=0;
}else
{relay=0;
SPEAKER=0;
vib=0;
}if(til==1)
{led=0;
}if(til==0)
{led=1;
}/*if(temp4<318)
{led=0;
}if(temp4>320)
{led=1;
}*/
}}
68