Home Automation with any remote

Hello Everyone,

its Iqbal and i m willing to design a project as home automation relay switch.

first of all i am very beginner in arduino whoever help me in this project please explain briefly. thanx in advance.

about project i am working on arduino UNO. i have 4-channel 12V relay module, 5No led, 5 touch switch, iR sensor, any iR remote. 1. I want to switched ON my every relay module from switch as well as remote, fifth switch will be the master switch for all switches if i press fifth switch all switch/relay turned ON again press then turned OFF. 2. every switch contain led which which represents each switch turned ON/Off position separately uses separate arduiono i/o Pin other than relay. 3. special feature : i dont want to use remote button reading using serial monitor. but i want something special feature about remote configuration. which is: after uploading program in arduino, when i press and hold switch 1 key for 3 seconds the switch 1 LED start blinking as signal for 10 second and demand to assign a remote key for configuration, when i press any key from remote it saves that key as switch 1 and blinking function over. same as for other relay.

waiting for help.

Sounds good. Come back when you actually do some work and have a real question.

dear INTP,

Do not criticize if you cant help anyone. i have made this same with the help of arduino site forum comments. but part of assigning remote button is remaining. i will show you completed very soon.

professorjee: dear INTP,

Do not criticize if you cant help anyone. i have made this same with the help of arduino site forum comments. but part of assigning remote button is remaining. i will show you completed very soon.

He didn't criticize and I am pretty sure he could help a lot if you gave him something to work with.

Thanx. actually i got stuck in my question no 3. if you see above in my questions. else is easy part but i am not expert in arduino thats why i want expert like you or any to code for me. please. may be what i have done will may not be usable for you. its simple what i have done. arduino uno with 4-channel relay along with lamp and switch. question 3 is still remaining and i have no idea how to start.

i have initialize 4 relay output, 5 switch input and 5 led output. no remote is added yet because i dont want to add remote from code, but read from switch ( see question 3).

awaiting for help.

If you want to commission someone to write your program for you then you need to post in the 'Gigs and Collaborations' section and I'm sure that someone will quote you a price for the work.

i dont want anyone to write program for me. i just need help in a function i needed " to assign a remote key by hold and pressing a switch as i mentioned in question#3. Thats it . i have tried much but i didnt get success, also i am a beginner in arduino.

Then post what you did.

this is what i have done yet. 4 relay with separate pin consuming LED turns ON/OFF by separate switch. IR function and master switch function is remaining. help me out. please keep in mind i am beginner and learning here from like you and my other brothers on this site.

CODE

/* home automation with switch as well as remote */ boolean latch = false;

define relay1 2 // this is the pin used to switch the relay1

define relay2 3 // this is the pin used to switch the relay2

define relay3 4 // this is the pin used to switch the relay3

define relay4 5 // this is the pin used to switch the relay4

define Switch1 6 // this is the switch1 output

define Switch2 7 // this is the switch1 output

define Switch3 8 // this is the switch1 output

define Switch4 9 // this is the switch1 output

//# define Switch5 10 // this is the Master switch output

define Vcc 11 // this is the pin used to act as +5v for the switch

define LED1 A0 // LED1

define LED2 A1 // LED2

define LED3 A2 // LED3

define LED4 A3 // LED4

//# define LED4 A4 // Master LED //# define IR A5 // IR Sensor input

define Vcc 11 // this is the pin used to act as +5v for the switch

void setup() { Serial.begin(9600); // used for debugging

pinMode(relay1, OUTPUT); digitalWrite(relay1,LOW); // turn OFF the relay1 pinMode(Switch1, INPUT); pinMode(LED1, OUTPUT); digitalWrite(LED1, LOW); // turn LED1 off

pinMode(relay2, OUTPUT); digitalWrite(relay2,LOW); // turn OFF the relay2 pinMode(Switch2, INPUT); pinMode(LED2, OUTPUT); digitalWrite(LED2, LOW); // turn LED2 off

pinMode(relay3, OUTPUT); digitalWrite(relay3,LOW); // turn OFF the relay3 pinMode(Switch3, INPUT); pinMode(LED3, OUTPUT); digitalWrite(LED3, LOW); // turn LED3 off

pinMode(relay4, OUTPUT); digitalWrite(relay4,LOW); // turn OFF the relay4 pinMode(Switch4, INPUT); pinMode(LED4, OUTPUT); digitalWrite(LED4, LOW); // turn LED4 off

pinMode(Vcc, OUTPUT); digitalWrite(Vcc,HIGH);// this pin will supply 5 volts

} void loop() { // turn switch1 ON on first touch if ((digitalRead(Switch1) == HIGH) && (latch == false)) { digitalWrite(relay1, HIGH); // relay1 ON Serial.println("relay1 ON"); digitalWrite(LED1, HIGH); // turn LED1 ON latch = true; // wait here until the Switch1 is no longer touched while ((digitalRead(Switch1) == HIGH)){ digitalWrite(LED1, LOW); // turn LED1 OFF delay(500); // try to stop debounce } } // turn switch2 ON on first touch if ((digitalRead(Switch2) == HIGH) && (latch == false)) { digitalWrite(relay2, HIGH); // relay2 ON Serial.println("relay2 ON"); digitalWrite(LED2, HIGH); // turn LED2 ON latch = true; // wait here until the Switch2 is no longer touched while ((digitalRead(Switch2) == HIGH)){ digitalWrite(LED2, LOW); // turn LED2 OFF delay(500); // try to stop debounce } } // turn switch3 ON on first touch if ((digitalRead(Switch3) == HIGH) && (latch == false)) { digitalWrite(relay3, HIGH); // relay3 ON Serial.println("relay3 ON"); digitalWrite(LED3, HIGH); // turn LED3 ON latch = true; // wait here until the Switch3 is no longer touched while ((digitalRead(Switch3) == HIGH)){ digitalWrite(LED3, LOW); // turn LED3 OFF delay(500); // try to stop debounce } } // turn switch4 ON on first touch if ((digitalRead(Switch4) == HIGH) && (latch == false)) { digitalWrite(relay4, HIGH); // relay4 ON Serial.println("relay4 ON"); digitalWrite(LED4, HIGH); // turn LED4 ON latch = true; // wait here until the Switch4 is no longer touched while ((digitalRead(Switch4) == HIGH)){ digitalWrite(LED4, LOW); // turn LED4 OFF delay(500); // try to stop debounce } }

// turn relay1 OFF on second touch if ((digitalRead(Switch1) == HIGH) && (latch == true)) { digitalWrite(relay1, LOW); // relay1 OFF Serial.println("Relay1 OFF"); digitalWrite(LED1, HIGH); // turn LED1 ON latch = false; // wait here until the Switch1 is no longer touched while ((digitalRead(Switch1) == HIGH)){ digitalWrite(LED1, LOW); // turn LED1 OFF delay(500); // try to stop debounce } } // turn relay2 OFF on second touch if ((digitalRead(Switch2) == HIGH) && (latch == true)) { digitalWrite(relay2, LOW); // relay2 OFF Serial.println("Relay2 OFF"); digitalWrite(LED2, HIGH); // turn LED2 ON latch = false; // wait here until the Switch2 is no longer touched while ((digitalRead(Switch2) == HIGH)){ digitalWrite(LED2, LOW); // turn LED2 OFF delay(500); // try to stop debounce } } // turn relay3 OFF on second touch if ((digitalRead(Switch3) == HIGH) && (latch == true)) { digitalWrite(relay3, LOW); // relay3 OFF Serial.println("Relay3 OFF"); digitalWrite(LED3, HIGH); // turn LED3 ON latch = false; // wait here until the Switch3 is no longer touched while ((digitalRead(Switch3) == HIGH)){ digitalWrite(LED3, LOW); // turn LED3 OFF delay(500); // try to stop debounce } } // turn relay4 OFF on second touch if ((digitalRead(Switch4) == HIGH) && (latch == true)) { digitalWrite(relay4, LOW); // relay4 OFF Serial.println("Relay4 OFF"); digitalWrite(LED4, HIGH); // turn LED4 ON latch = false; // wait here until the Switch4 is no longer touched while ((digitalRead(Switch4) == HIGH)){ digitalWrite(LED4, LOW); // turn LED4 OFF delay(500); // try to stop debounce } } }

Format your code with Ctrl+T in the IDE and then post it in code tags.

Also, I recommend defining pins as const uint8_t instead of precompiler defines. That makes error messages much more understandable.

yes. after removing some errors its working. thanx all of you. ... now help me out to draw sketch for assigning remote key to any switch by press & hold a desire key to be set. means switch 1 also remote assigned key work same for turning relay ON/OFF. while assigning key from remote for desire switch led starts blinking until set the key from remote.

I still haven't seen what you got, because I refuse to look at unformated code that may be missing stuff (like array brackets) because it is not in code tags.

Format your corrected code with Ctrl+T in the IDE and then post it in code tags. Last strike, by the way.

please find below working sketch of 4 switch which is operating separate led as well. i have not added relay yet. and also i have changed program on your recommendation. .... now i want y to add some functions as a favor as i want above. 1. add master key for all switches which works on last switches state. 2. remote key assigning by press and hold switch, which start blinking by press and hold any switch and demand for assigning remote key, it should wait for 15 sec for remote key if remote key has not pressed within 15 sec then it goes to normal mode.

int a=2; int b=3; int c=4; int d=5; int count1=6; int count2=7; int count3=8; int count4=9;

void setup() { pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(2,INPUT); pinMode(3,INPUT); pinMode(4,INPUT); pinMode(5,INPUT); }

void loop() { delay(100); a=digitalRead(2); b=digitalRead(3); c=digitalRead(4); d=digitalRead(5);

if(a==1) { if(count1==0) {count1=1;} else {count1=0;}

while(a==1) {a=digitalRead(2);} }

digitalWrite(6,count1);

if(b==1) { if(count2==0) {count2=1;} else {count2=0;}

while(b==1) {b=digitalRead(3);} }

digitalWrite(7,count2);

if(c==1) { if(count3==0) {count3=1;} else {count3=0;}

while(c==1) {c=digitalRead(4);} }

digitalWrite(8,count3);

if(d==1) { if(count4==0) {count4=1;} else {count4=0;}

while(d==1) {d=digitalRead(5);} }

digitalWrite(9,count4);

}

waiting for your help

picture

STILL waiting for you to read my posts. You stress in each and every post, that you expect help, but are not willing to even do the minimum, especially not without being asked multiple times. Strike 3. I'm out.

hey ElCron,

i do not want you to mind.
i have done the sketch properly and tested successfully this time . i also have pictures.

pictures