am simulating a home automation system using 8051 and relays, i have a code and the circuit is working ok but am failing to send commands to switch the bulbs on, some one help me how to do it with help of compim
#include<REG52.h>
unsigned char light;
int interpret;
/* The pins of the port 0 are connected to power line of various
home appliances through the control circuitry to control them by
on/o? the power supply. */
sbit light1=P0^0; // Pin connected to the control circuit of the Light 1.
sbit light2=P0^1;
sbit TV=P0^2; // Pin connected to control circuit of power supply of TV.
sbit PC = P0^3;
sbit oven = P0^4;
sbit washing = P0^5;
sbit coller = P0^6;
sbit CD = P0^7;
void main (void)
{
int k=0;
char i;
init(); ES=1; EA=1;
for (i=0;i<4;i++){
packet=0;
}
index=0;
interpret=0;
while(1)
{
{
P0=light1;
delay(1000);
}
}}
void delay (int m)
{ int z;
z=m;
while ( m >0)
{ m--;}
}
void serialisr() interrupt 4
{
unsigned char y;
char i;
RI=0;
y=SBUF;
TI=0; SBUF=y; while (!TI);TI=0;
packet[index]=y;
index++;
if (y=='z') {interpret =1; index = 0;}
else interpret = 0;
if (interpret==1)
{
switch (packet[0])
{
case 'A':
light1=1; // switch on the bulb1
break;
case 'B':
light1=0; // switch off the bulb1
break;
case 'C':
light2=1; // switch on the bulb2
break;
case 'D':
light2=0; // switch off the bulb2// // switch on Washing machine
break;
case 'E':
TV=1; // switch on the TV
break;
case 'F':
TV=0; // switch off The TV
break;
case 'G':
PC=1; // switch on PC
break;
case 'H':
PC=0; // switch o? the PC
break;
case 'I':
oven=1; // switch on oven
break;
case 'J':
oven=0; // switch o? oven
break;
case 'K':
washing=1; // switch on the washing machine
break;
case 'L':
washing=0; // switch o? the washing machine
break;
case 'M':
coller=1; // switch on cooler
break;
case 'N':
coller=0; // switch o? the cooler
break;
case 'O':
CD=1; // switch on CD player
break;
case 'P':
CD=0; // switch o? CD player
break;
}
for (i=0;i<8;i++){
packet=0;
}
interpret=0;
}}
am using the above code to send commands to the circuit to switch on or off, and i have failed to send command. i need help how