You are on page 1of 4

Temperature monitoring codes***********************

//Code for ADC input


rd = 1;
wr = 1;
wr=0;
wr = 1;
while(intr==0);
// Data converted into Digital form
rd = 0;
x = TEMPERATURE;
temperature = TEMPERATURE;

datatolcd[13] = (temperature / 100) + '0';


temp = (temperature % 100);
datatolcd[14] = temp/10 + '0';
datatolcd[15] = temp%10 + '0';

lcdcmd(0xC0);
MSDelay(10);

for(i = 0; i< 16; i++)


{
lcddata(datatolcd[i]);
MSDelay(1);
}

// transmission
if((average_beats_per_min<60) || (average_beats_per_min>95) ||
(temperature > 45))
{

HEART_RATE_NORMAL_LED = OFF;
HEART_RATE_ABNORMAL_LED = ON;
// BUZZER = ON;
for(i=0; i<8; i++)
{

SBUF = send_sms_command[i];
MSDelay(5);

for(i=0; i<13; i++)


{

SBUF = destination1[i];
MSDelay(5);

for(i=0; i<16; i++)


{
SBUF = datatolcd[i];
MSDelay(5);
}

else
{
HEART_RATE_NORMAL_LED = ON;
HEART_RATE_ABNORMAL_LED = OFF;
// BUZZER = OFF;
}

if(EMERGENCY_BUTTON == PRESSED)
{

lcdcmd(0xC0);
MSDelay(10);

for(i = 0; i< 16; i++)


{
lcddata(emergency[i]);
MSDelay(1);
}

HEART_RATE_NORMAL_LED = OFF;
HEART_RATE_ABNORMAL_LED = ON;
// BUZZER = ON;
for(i=0; i<8; i++)
{

SBUF = send_sms_command[i];
MSDelay(5);

for(i=0; i<13; i++)


{

SBUF = destination1[i];
MSDelay(5);

for(i=0; i<16; i++)


{
SBUF =emergency[i];
MSDelay(5);
}

MSDelay(5000);
}

//*********************************************************************************
************
if( message_ended == YES )
{
command_incorrect_char_received = 0;
for(index = 0; index < 8; index++)
{
if((status[index] != messege_buffer[index]))
command_incorrect_char_received++;
}

if(command_incorrect_char_received == 0)
{

HEART_RATE_NORMAL_LED = ON;
HEART_RATE_ABNORMAL_LED = ON;
MSDelay(1000);
HEART_RATE_NORMAL_LED = OFF;
HEART_RATE_ABNORMAL_LED = OFF;
MSDelay(1000);
for(i=0; i<8; i++)
{

SBUF = send_sms_command[i];
MSDelay(5);

for(i=0; i<13; i++)


{

SBUF = destination1[i];
MSDelay(5);

for(i=0; i<16; i++)


{
SBUF = datatolcd[i];
MSDelay(5);
}

HEART_RATE_NORMAL_LED = ON;
HEART_RATE_ABNORMAL_LED = ON;
MSDelay(1000);
HEART_RATE_NORMAL_LED = OFF;
HEART_RATE_ABNORMAL_LED = OFF;
MSDelay(1000);

MSDelay(5000);

}
//*********************************************************************************
**********

} // end of super while

void lcdcmd (unsigned char value)


{
LCD = value; // put value on the pins
RS = 0;
RW = 0;
EN = 1; // strobe the enable pin
MSDelay(1);
EN = 0;
return;
}

void lcddata (unsigned char value)


{
LCD = value; // put the value on the pins
RS = 1;
RW = 0;
EN = 1; // strobe the enable pin
MSDelay(1);
EN = 0;
return;
}

void MSDelay (unsigned int itime)


{
unsigned char i,j;
for(i=0; i<itime; i++)
{
for(j=0; j<100; j++)
{;}
}
}

void timer0() interrupt 1 // timer0 runs from 0x0000 to 0xFFFF


{
timer0_interrupt_counter++;
}

You might also like