You are on page 1of 6

#include <REGX51.

H>

/* special function register declarations */


/* for the intended 8051 derivative */
void msdelay(unsigned int );
#include<string.h>
sbit LCD_en=P3^4;
sbit LCD_rs=P3^5;
void LCD_delay(unsigned char ms);
void LCD_enable();
void LCD_command(unsigned char command);
void LCD_putc(unsigned char ascii);
void LCD_puts(unsigned char *lcd_string);
void LCD_init();
void Delay_1sec();
#define LCD_DELAY 1535 /* Delay for 1 ms */
#define LCD_clear() LCD_command(0x1) /* Clear display LCD */
#define LCD_origin() LCD_command(0x2) /* Set to origin LCD */
#define LCD_row1() LCD_command(0x80) /* Begin at Line 1 */
#define LCD_row2() LCD_command(0xC0) /* Begin at Line 2 */

#include <stdio.h> /* prototype declarations for I/O functions */


sbit MES1 = P2^0;
sbit MES2 = P2^1;
sbit MES3 = P2^2;
sbit MES4 = P2^3;
sbit MES5 = P2^4;
sbit MES6 = P2^5;
sbit MES7 = P2^6;
sbit MES8 = P2^7;
int i;
void time1ms();
void delay(int n);
unsigned int p,num;
//INTRUDER=0;
/****************/
/* main program */
/****************/
void main (void) { /* execution starts here after stack init */
SCON = 0x52; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xfd; /* TH1: reload value for 9600 baud@11.0592mhz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
LCD_init(); // LCD initialization
LCD_clear(); // clearing lcd display
// initializing serial communication
LCD_row1(); // setting cursor into first row
of lcd

LCD_puts("FIRE DETECTOR");
LCD_row2(); // setting cursor into first row
of lcd
//LCD_putc(' ');
LCD_puts("USING CAMERA");
//LCD_puts("FAN ON");

while (1) {
P2=0x00;
if (MES1 == 1)
{

Delay_1sec();
p=rand()%6;
num= p;
switch(num)
{
case 0:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 27 DEG");
printf ("TEMP: 27 DEG");
Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 27 DEG");
printf ("TEMP: 27 DEG");
Delay_1sec();
Delay_1sec();
break;
case 1:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 34 DEG");
printf ("TEMP: 34 DEG");
Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 34 DEG");
printf ("TEMP: 31 DEG");
Delay_1sec();
Delay_1sec();
break;
case 2:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 35 DEG");
printf ("TEMP: 35 DEG");
Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 35 DEG");
printf ("TEMP: 35 DEG");
Delay_1sec();
Delay_1sec();
break;

case 3:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 24 DEG");
printf ("TEMP: 24 DEG");
Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 24 DEG");
printf ("TEMP: 23 DEG");
Delay_1sec();
Delay_1sec();
break;
case 4:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 22 DEG");
printf ("TEMP: 22 DEG");

Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 22 DEG");
printf ("TEMP: 22 DEG");
MES8 =1;
Delay_1sec();

Delay_1sec();
MES8 =0;
break;
case 5:
LCD_clear();
LCD_row1();
LCD_puts("TEMP: 23 DEG");
printf ("TEMP: 23 DEG");
Delay_1sec();
Delay_1sec();
LCD_clear();
LCD_row2();
LCD_puts("TEMP: 23 DEG");
printf ("TEMP: 23 DEG");
Delay_1sec();
Delay_1sec();
break;
}
printf ("TEMPERATURE MONITORED UPDATED IN LCD AND PC");
LCD_clear();
//LCD_puts("FINGER MATCHED");

You might also like