Wireless based door open and closed system
Published Tuesday, 4 October 2011 by gk in#include <reg51.h>
sfr ldata=0x90;
sbit SW = P3^7;
sbit rs = P3^5;
sbit en = P3^6;
sbit m1=P2^1;
sbit m2=P2^2;
void init_lcd();
void cmd_lcd(unsigned char );
void dat_lcd(unsigned char );
void msdelay(unsigned int);
void wrt_lcd(unsigned *);
void main()
{
unsigned int i;
init_lcd();
wrt_lcd("CONTROL SYSTEM");
msdelay(10000000);
msdelay(9000000);
if(SW==0)
{
init_lcd();
for(i=0;i<50000;i++)
{
m1=0;
m2=1;
}
while(1)
{
m1=0;
m2=0;
init_lcd();
wrt_lcd(" DOOR CLOSED");
msdelay(9000);
msdelay(9000);
}
}
else
{
init_lcd();
for(i=0;i<50000;i++)
{
m1=1;
m2=0;
}
while(1)
{
m1=0;
m2=0;
init_lcd();
wrt_lcd(" DOOR OPEN");
msdelay(900000);
msdelay(9000000);
}
}
}
void msdelay(unsigned int val)
{
int a,b;
for(a=0;a<1275;a++);
for(b=0;b<val;b++);
}
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x0E);
cmd_lcd(0x80);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char a)
{
ldata= a;
rs = 0;
en = 1;
msdelay(200);
en = 0;
msdelay(100);
}
void dat_lcd(unsigned char a)
{
ldata = a;
rs = 1;
en = 1;
msdelay(200);
en = 0;
msdelay(100);
}
void wrt_lcd(unsigned char *p)
{
while(*p!='\0')
{
dat_lcd(*p);
p++;
}
}
sfr ldata=0x90;
sbit SW = P3^7;
sbit rs = P3^5;
sbit en = P3^6;
sbit m1=P2^1;
sbit m2=P2^2;
void init_lcd();
void cmd_lcd(unsigned char );
void dat_lcd(unsigned char );
void msdelay(unsigned int);
void wrt_lcd(unsigned *);
void main()
{
unsigned int i;
init_lcd();
wrt_lcd("CONTROL SYSTEM");
msdelay(10000000);
msdelay(9000000);
if(SW==0)
{
init_lcd();
for(i=0;i<50000;i++)
{
m1=0;
m2=1;
}
while(1)
{
m1=0;
m2=0;
init_lcd();
wrt_lcd(" DOOR CLOSED");
msdelay(9000);
msdelay(9000);
}
}
else
{
init_lcd();
for(i=0;i<50000;i++)
{
m1=1;
m2=0;
}
while(1)
{
m1=0;
m2=0;
init_lcd();
wrt_lcd(" DOOR OPEN");
msdelay(900000);
msdelay(9000000);
}
}
}
void msdelay(unsigned int val)
{
int a,b;
for(a=0;a<1275;a++);
for(b=0;b<val;b++);
}
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x0E);
cmd_lcd(0x80);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char a)
{
ldata= a;
rs = 0;
en = 1;
msdelay(200);
en = 0;
msdelay(100);
}
void dat_lcd(unsigned char a)
{
ldata = a;
rs = 1;
en = 1;
msdelay(200);
en = 0;
msdelay(100);
}
void wrt_lcd(unsigned char *p)
{
while(*p!='\0')
{
dat_lcd(*p);
p++;
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment