Skip to main content

home appliance control 8051 code

#include <REGX52.H>
#include <string.h>
#include <ctype.h>
#include "lcd.c"
#include "serial.c"

#define MAX_DELAY() delay(65000)

sbit Device=P0^0;

bit Dev_Stat=0;

unsigned char SE_INTR_ST = 0;
unsigned char re_str[6], number[14];
unsigned char dummy[6];


void intro()
{
 lcd_init();
 lcd_str(" Applaince Ctrl ",0x80);
 lcd_str("Using GSM - 8051",0xc0);
 MAX_DELAY();MAX_DELAY();
MAX_DELAY();MAX_DELAY();
 lcd_clr();
 }

void serial0() interrupt 4
{
char z;
if(RI==1)
{
z=SBUF;RI=0;
if(z=='+')
SE_INTR_ST = 1;
}
}

void temp_receive(unsigned char r)
{
unsigned char ten;
do
{
ten=se_rx();
}while(ten!=r);
}

void gsmread(const unsigned char *str,char limit,unsigned char *dummy_str)
{
unsigned char i,temp,lmt_chk = 0;
lcd_clr();
while(*str!='\0')
{
se_tx(*str);
str++;
}
se_tx('\r');//se_tx(0x0a);
if(limit==1)
{
for(i=0;i<2;i++)
temp_receive('"');temp_receive('1');
i=0;
do
{
temp=se_rx();
if(isdigit(temp))
{
number[i]=temp; i++;
}
}while(temp!='"');
temp_receive(0x0d);
number[i]='\0';
}
// if(RI == 1)
// do
// {
// temp=se_rx();
// }
// while(isalnum(temp) || (temp == '=') || (temp == '+'));
if(limit!=1)
temp_receive('O');
i=0;lmt_chk = 0;
do
{
temp=se_rx();
if(isalnum(temp))
{
lmt_chk = 1;
dummy_str[i]=toupper(temp); i++;
}
}while(((temp!=0x0d) || (lmt_chk == 0)) && (i < 10));
dummy_str[i]='\0';

if(limit==1)
{
temp_receive(0x0d);
temp_receive(0x0d);
temp=se_rx();
lcd_clr();
}
delay(5000);
}

void msgdelete()
{
gsmread("AT",0,dummy);
lcd_str(dummy,0xc0);delay(50000);
gsmread("AT+CMGF=1",0,dummy);
lcd_str(dummy,0xc0);delay(50000);
gsmread("AT+CMGD=1",0,dummy);
lcd_str(dummy,0xc0);delay(50000);
}

void main()
{
unsigned char i=0;
Device = 0;
intro();
se_init();
delay(35000);//se_gsm("Testing Testing");while(1);
msgdelete();
lcd_clr();
delay(50000);
TI = 0; RI = 0;
delay(5000);
EA=1; //Enabling Global interrupt
ES=1; //Enabling Serial interrupt
while(1)
{
 if(SE_INTR_ST == 1)
{
IE=0x00;

SE_INTR_ST = 0;
lcd_clr();
lcd_str("Msg Received",0x80);
delay(65000);delay(65000);
TI = 0; RI = 0;
delay(65000);

gsmread("AT",0,dummy); //lcd_str(dummy,0xc0);delay(50000);
gsmread("AT+CMGF=1",0, dummy); //lcd_str(dummy,0xc0);delay(50000);
gsmread("AT+CMGR=1",1, re_str); //lcd_str(re_str,0xc0);delay(50000);
gsmread("AT+CMGD=1",0, dummy); //lcd_str(dummy,0xc0);delay(50000);

lcd_clr();
lcd_str(re_str,0x80);
// lcd_str(number,0xc0);
MAX_DELAY();MAX_DELAY();
// MAX_DELAY();MAX_DELAY();
lcd_clr();
if(!strcmp(re_str,"DONN"))
{
lcd_str("Device turned On",0x80);
Device = 1;Dev_Stat = 1;
}
else if(!strcmp(re_str,"DOFF"))
{
lcd_str("Device turnd Off",0x80);
Device = 0;Dev_Stat = 0;
}
else
{
lcd_str("  Wrong Format  ",0x80);
}
MAX_DELAY();MAX_DELAY(); MAX_DELAY();
IE=0x90;
}
else
{
lcd_clr();
lcd_str("No Msg Received",0x80);
if(Dev_Stat == 1)
{
lcd_str("Device turned On",0xc0);
}
else
{
lcd_str("Device turnd Off",0xc0);
}
while(SE_INTR_ST == 0);
}
}
}

Comments

Popular posts from this blog

Inverted Linear Quadtree: Efficient Top K Spatial Keyword Search

Inverted Linear Quadtree: Efficient Top K Spatial Keyword Search ABSTRACT: In this paper, With advances in geo-positioning technologies and geo-location services, there are a rapidly growing amount of spatiotextual objects collected in many applications such as location based services and social networks, in which an object is described by its spatial location and a set of keywords (terms). Consequently, the study of spatial keyword search which explores both location and textual description of the objects has attracted great attention from the commercial organizations and research communities. In the paper, we study two fundamental problems in the spatial keyword queries: top k spatial keyword search (TOPK-SK), and batch top k spatial keyword search (BTOPK-SK). Given a set of spatio-textual objects, a query location and a set of query keywords, the TOPK-SK retrieves the closest k objects each of which contains all keywords in the query. BTOPK-SK is the batch processing of sets...

A simple and reliable touch sensitive security system CODING

#include <REGX51.H> #include "lcd.c" #define MAX_DELAY() delay(65000) sbit Vibra_Sense=P3^1; sbit Buz=P1^0; void intro() {  lcd_init();  lcd_str("Touch Sensitive ",0x80);  lcd_str("Security System ",0xc0);  MAX_DELAY();MAX_DELAY();  lcd_clr();  }  void main()  { unsigned int i = 0, j= 0; intro();    while(1)    { lcd_str("Security Syst On",0x80); lcd_str("No Vibra Detectd",0xc0); Buz = 1; if(Vibra_Sense == 1) { while(Vibra_Sense == 1) delay(1000); } else { while(Vibra_Sense == 0) delay(1000); } Buz = 0; lcd_str("Vibraton Detectd",0xc0);delay(65000); while(1);    }  }

A Time Efficient Approach for Detecting Errors in Big Sensor Data on Cloud

A Time Efficient Approach for Detecting Errors in Big Sensor Data on Cloud Abstract                                                                                                                                                      ...