RF-home-automation-final

Arduino based RF Home Automation System

Arduino

This project is help you to automate the home appliance and take all load(light, fan) under RF control. We used a 2 channel relay Arduino shield as Load driver. Connect Arduino as per below diagram

RF-home-automation-system

 

Below is a Sample code

const int load1pin = 9;
const int load2pin = 10;
const int load3pin = 11;
const int load4pin = 12;
const int load5pin = 13;
const int remd0pin = 6;
const int remd1pin = 5;
const int remd2pin = 4;
const int remd3pin = 3;
const int remlpin = 2;

bool remd0=false,remd1=false,remd2=false,remd3=false,reml=false;
bool loadAstat=false,loadBstat=false,loadCstat=false;
void setup() {
// put your setup code here, to run once:
pinMode(load1pin, OUTPUT);
pinMode(load2pin, OUTPUT);
pinMode(load3pin, OUTPUT);
pinMode(load4pin, OUTPUT);
pinMode(load5pin, OUTPUT);
//pinMode(remgndpin, OUTPUT);
// pinMode(remvccpin, OUTPUT);
pinMode(remd0pin, INPUT);
pinMode(remd1pin, INPUT);
pinMode(remd2pin, INPUT);
pinMode(remd3pin, INPUT);
pinMode(remlpin, INPUT);

// digitalWrite(remgndpin, LOW);
//digitalWrite(remvccpin, HIGH);

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
//digitalWrite(load1pin, HIGH);
digitalWrite(load2pin, loadCstat);
digitalWrite(load3pin, loadAstat);
digitalWrite(load4pin, loadBstat);
//digitalWrite(load5pin, LOW);

remd0=digitalRead(remd0pin);
remd1=digitalRead(remd1pin);
remd2=digitalRead(remd2pin);
remd3=digitalRead(remd3pin);
reml=digitalRead(remlpin);

Serial.print(“remd0:”);
Serial.print(remd0);
Serial.print(“:remd1:”);
Serial.print(remd1);
Serial.print(“:remd2:”);
Serial.print(remd3);
Serial.print(“:remd3:”);
Serial.print(remd3);
Serial.print(“remL:”);
Serial.println(reml);

if(remd0==true){
if(loadAstat)
loadAstat=false;
else
loadAstat=true;
delay(1000);
}
if(remd1==true){
if(loadBstat)
loadBstat=false;
else
loadBstat=true;
delay(1000);
}

if(remd2==true){
if(loadCstat)
loadCstat=false;
else
loadCstat=true;
delay(1000);
}

}

 

Leave a Reply