Bluetooth Controlled Home Appliances

Published on August 2017 | Categories: Documents | Downloads: 34 | Comments: 0 | Views: 381
of 2
Download PDF   Embed   Report

Comments

Content

#include<reg51.h>
#include"lcd.h"
#include"uart.h"
sbit lamp=P2^0;
sbit motor=P2^1;
void main()
{
unsigned char read[4],bulb[4]="abcd",fan[4]="bcde";
unsigned char i,count1,count2,j=0,k=0;
motor=lamp=0;
lcd_init();
uart_init();
delay_ms(50);
lcd_stringxy(0,0,"Password based");
lcd_stringxy(1,0,"Load control");
delay_ms(5000);
lcd_cmd(0x01);
while(1)
{
count1=count2=0;
lcd_cmd(0x80);
for(i=0;i<4;i++)
{
read[i]=rx_data();
}
for(i=0;i<4;i++)
{
lcd_data(read[i]);
}
for(i=0;i<4;i++)
{
if(read[i]==bulb[i])
count1++;
if(read[i]==fan[i])
count2++;
}
if(count1==4)
{
j++;
if(j%2==1)
lcd_stringxy(0,6,"Bulb on ");
else
lcd_stringxy(0,6,"Bulb off");
motor=~motor;
}
else if(count2==4)
{
k++;
if(k%2==1)
lcd_stringxy(1,0,"Fan on ");
else
lcd_stringxy(1,0,"Fan off");
lamp=~lamp;
}
else
{

lcd_stringxy("pwd is wrong ");
}
}
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close