Programming
Programming
PROGRAMMING
#include<reg52.h>
#include<stdio.h>
#include<string.h>
sbit AW=P1^0;
sbit AL=P1^1;
sbit AL1=P1^2;
sbit BW=P1^3;
sbit BL=P1^4;
sbit BL1=P1^5;
// FUNCTION TO
{
unsigned char i;
TR1=1;
// TIMER1 RUN
for(i=0;*p!='\0';i++)
{
SBUF=*p;
*p++;
while(TI==0)
{}
TI=0;
}
SBUF=0X0D;
// INDICATE END OF
COMMAND
while(TI==0)
{}
TI=0;
TR1=0;
// FUNCTION TO
{
unsigned char i;
TR1=1;
// TIMER1 RUN
for(i=0;*p!='\0';i++)
{
SBUF=*p;
*p++;
while(TI==0)
{}
TI=0;
}
SBUF=0X1A;
MESSAGE 'ctrl+z'
// INDICATE END OF
while(TI==0)
{}
TI=0;
TR1=0;
void sendsms(void)
{
transmit_d(setsms);
transmit_d(setmod);
transmit_d(sendnum);
}
void receive()
TR1=1;
while(RI==0) {}
unsigned char i;
TR1=1;
for(i=0;i<n;i++) {
while(RI==0) {}
temp[i]=SBUF;
// COPY TO 'temp'
RI=0;
TR1=0;
temp[i]='\0';
*p=*p1;
*p++;*p1++;
p='\0';}
if(*p==*p1)comp_bit=1;
else
comp_bit=0;
break;
*p++;*p1++;
return (comp_bit); }
void main()
{
P1=0x00;
P2=0x00;
P0=0x00;
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
AW=AL=AL1=0;
transmit_d(att);transmit_d(att);
transmit_d(att);delay(500);
transmit_d(delet1);delay(1000);
transmit_d(delet2);delay(1000);
while(1)
{
transmit_d(att);
transmit_d(att);
transmit_d(delet1);delay(1000);
transmit_d(delet2);delay(1000);
receive();
while(serialdata!='+') receive();
receive1(5);
str_comp(temp,mes_indicate);delay(4000);
if(comp_bit==1)
{
delay(10000);
transmit_d(read);
receive();
while(serialdata!=0x0A) receive();receive();
while(serialdata!=0x0A) receive();
receive1(5);
delay(5000); transmit_d(temp);
str_comp(temp,l1an);
if(comp_bit==1)
{
AW=1;
sendsms(); transmit1(wateron); delay(100);
//sendsms1(); transmit1(light1on); delay(5000);
}
else
{
str_comp(temp,l1af);
if(comp_bit==1)
{
AW=0;
else
{
str_comp(temp,l2an);
if(comp_bit==1)
{
AL=1;
else
{
str_comp(temp,l3an);
if(comp_bit==1)
{AL1=1;delay(500);
else
{
str_comp(temp,l3af);
if(comp_bit==1)
{AL1=0;delay(500);
}
else
{
str_comp(temp,coa2);
if(comp_bit==1)
{
else
{
str_comp(temp,l1bn);
if(comp_bit==1)
{
BW=1;
sendsms(); transmit1(wateron); delay(100);
//sendsms1(); transmit1(light1on); delay(5000);
}
else
{
str_comp(temp,l1bf);
if(comp_bit==1)
{
BW=0;
else
{
str_comp(temp,l2bn);
if(comp_bit==1)
{
BL=1;
//
else
{
str_comp(temp,l3bn);
if(comp_bit==1)
{BL1=1;delay(500);
else
{
str_comp(temp,l3bf);
if(comp_bit==1)
{BL1=0;delay(500);
if(comp_bit==1)
{
sendsms(); transmit1(condition1on); delay(100);
BW=1;BL1=1;delay(300000);BL1=0;BL=1;delay(200000);BL=0;
BW=0;
}
else
{
str_comp(temp,cob2);
if(comp_bit==1)
{
sendsms(); transmit1(condition2on); delay(100);
BW=1;BL1=0;BL=1;delay(400000);BL=0;
BW=0;
}
else{
str_comp(temp,l1on);
if(comp_bit==1)
{
WATER=1;
sendsms(); transmit1(wateron); delay(100);
//sendsms1(); transmit1(light1on); delay(5000);
}
else
{
str_comp(temp,l1of);
if(comp_bit==1)
{
WATER=0;
else
{
str_comp(temp,l2on);
if(comp_bit==1)
{
L2=1;
else
{
str_comp(temp,l3on);
if(comp_bit==1)
{L3=1;delay(500);
else
{
str_comp(temp,l3of);
if(comp_bit==1)
{L3=0;delay(500);
}
else
{
str_comp(temp,con2);
if(comp_bit==1)
{
sendsms(); transmit1(condition2on); delay(100);
WATER=1;L3=0;L2=1;delay(400000);L2=0;
WATER=0;
}}}}}}}
}}}}}}}}
}}}}}}}}
delay(100);
transmit_d(delet1);delay(1000);
transmit_d(delet2);delay(1000);
transmit_d(delet3);delay(1000);
}
else
{
transmit_d(delet1);delay(1000);
transmit_d(delet2);delay(1000);
transmit_d(delet3);delay(1000);
}
}