HOME AUTOMATION

Photo of author

By Jackson Taylor

HOME AUTOMATION USING ANDROID MOBILE


PROGRAM
int bulb = 8,fan=9;
unsigned char a;
void setup()
{              
  pinMode(bulb, OUTPUT);   pinMode(fan, OUTPUT);  
  digitalWrite(bulb, LOW);   digitalWrite(fan, LOW);
  Serial.begin(9600);
  Serial.println(“Home automation project “); Serial.println(” by Emerging Technologies”);
  digitalWrite(bulb, HIGH);Serial.println(“BULB ON”);
}
void loop() {
  if(Serial.available()>0){a=Serial.read();}
  if(a==’L’){digitalWrite(bulb, HIGH);//Serial.println(“BULB ON”);
}
 if(a==’l’){digitalWrite(bulb, LOW);
 }
  if(a==’0′){analogWrite(fan, 0);
}
if(a==’1′){analogWrite(fan, 50);}
  if(a==’2′){analogWrite(fan, 100);}
 if(a==’3′){analogWrite(fan, 150);}
  if(a==’4′){analogWrite(fan, 200);}
  if(a==’5′){analogWrite(fan, 255);}
 else{ digitalWrite(bulb, LOW); }
  }