Introduction: Home Automation With Arduino, Buttons ,LCD ,EEPROM AND Smart Phone
Now we can control full home with smart Phone
Step 1: Hardware Required
for home automation you can add different things i choose switching or relay
In this project you will control switcher by mobile .if mobile is not present you can also operate with keypad
I also add lcd in the project to see the the present status of switches.
hardware required in this project
Android Mobile
jumper cables
16 * 2 LCD display
HC-06 Bluetooth Module
Arduino uno or MEGA
Bread Board
10k ohm varible for LCD
Relay Module
For making own relay Module
Relay
Transister
Resisters
PCB board
Step 2: Software Required
https://play.google.com/store/apps/details?id=com....
Download this app for home automation it can control 8 relay at a time
Its also have a timer.
To program on arduino use Arduino IDE which is available on
Step 3: Programming for Bluetooth Module and Relay Module
this is the wiring sequence of relay module and relay module
This program is only for bluetooth and relay module
<p>#include <SoftwareSerial,h></p><p></p><p>SoftwareSerial mySerial(0, 1); // 1-RX, 0-TX - </p><p>int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3;</p><p> void setup() { mySerial.begin(9600);</p><p> pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);</p><p> }</p><p> void loop() {</p><p> char caracter = mySerial.read();</p><p> //--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); </p><p>}</p><p>if(caracter == 'a') { digitalWrite(ch1,LOW); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH);</p><p>}</p><p>if(caracter == 'b') { digitalWrite(ch2,LOW); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH);</p><p>}</p><p>if(caracter == 'c') { digitalWrite(ch3,LOW); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); }</p><p>if(caracter == 'd') { digitalWrite(ch4,LOW); } //---------------------------------ch4----------------------</p><p> delay(10); }</p>
Step 4: Now Adding LCD With Arduino
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
<p>#include <SoftwareSerial.h><br> SoftwareSerial mySerial(0, 1); #include <LiquidCrystal.h> int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) </p><p> void setup() { mySerial.begin(9600);</p><p> pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);</p><p>lcd.begin(16, 2);</p><p> }</p><p> void loop() {</p><p> char caracter = mySerial.read();</p><p> //--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON");</p><p>}</p><p>if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); }</p><p>if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); }</p><p>if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); }</p><p>if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); } //---------------------------------ch4----------------------</p><p> delay(10); }</p>
Attachments
Step 5: Adding Push Button in the Project
Now we are adding Buttons
i use four button you can use it according to requirement
<p>#include <SoftwareSerial.h> //</p><p> SoftwareSerial mySerial(0, 1); // 1-RX, 0-TX - #include <LiquidCrystal.h></p><p>int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) int switchPin[] = {6,7,8,9}; void setup() { mySerial.begin(9600);</p><p> pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);</p><p>lcd.begin(16, 2);</p><p>pinMode(switchPin[0], INPUT); digitalWrite(switchPin[0], HIGH); pinMode(switchPin[1], INPUT); digitalWrite(switchPin[1], HIGH); pinMode(switchPin[2], INPUT); digitalWrite(switchPin[2], HIGH); pinMode(switchPin[3], INPUT); digitalWrite(switchPin[3], HIGH); pinMode(switchPin[4], INPUT); digitalWrite(switchPin[4], HIGH); }</p><p> void loop() {</p><p> char caracter = mySerial.read();</p><p> //--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON");</p><p>}</p><p>if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); }</p><p>if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); }</p><p>if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); }</p><p>if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); } //---------------------------------ch4---------------------- if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); } if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON");// toggle running variable } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r4 OFF"); }</p><p> delay(0); }</p>
Attachments
Step 6: Now We Are Using EEPROM to Save Last Status of Switches
Using EEPROM
I am adding internal EEPROM to save the last status
If the device go out of power and again connected
it load the last status of switches
those switches which are on before power off now they are still on
<p>#include <SoftwareSerial.h> //</p><p> SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - #include <LiquidCrystal.h></p><p>#include <EEPROM.h></p><p>int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) int switchPin[] = {6,7,8,9}; void setup() { mySerial.begin(9600);</p><p> pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);</p><p>lcd.begin(16, 2);</p><p>pinMode(switchPin[0], INPUT); digitalWrite(switchPin[0], HIGH); pinMode(switchPin[1], INPUT); digitalWrite(switchPin[1], HIGH); pinMode(switchPin[2], INPUT); digitalWrite(switchPin[2], HIGH); pinMode(switchPin[3], INPUT); digitalWrite(switchPin[3], HIGH); pinMode(switchPin[4], INPUT); digitalWrite(switchPin[4], HIGH);</p><p> if (EEPROM.read(0) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(0) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(1) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(1) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(2) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(2) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(3) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(3) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r3 OFF"); // toggle running variable // indicate via LED } } </p><p> void loop() {</p><p> char caracter = mySerial.read();</p><p> //--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON"); EEPROM.write(0, 1); }</p><p>if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); EEPROM.write(0, 0); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); EEPROM.write(1, 1); }</p><p>if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); EEPROM.write(1, 0); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); EEPROM.write(2, 1); }</p><p>if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); EEPROM.write(2, 0); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); EEPROM.write(3, 1); }</p><p>if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); EEPROM.write(3, 0); } //---------------------------------ch4---------------------- if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); EEPROM.write(0, 1); } if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); EEPROM.write(0, 0); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); EEPROM.write(1, 1); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); EEPROM.write(1, 0); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); EEPROM.write(2, 1); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); EEPROM.write(2, 0); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON");// toggle running variable EEPROM.write(3, 1); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r4 OFF"); EEPROM.write(3, 0); }</p><p> delay(0); }</p>
Attachments
Step 7: Adding Sensers in the Project
If you want to add senser i think Arduino MEGA is Better because it has more pins than uno
if you want to use Arduino UNO Than use Shields

Participated in the
Automation Contest 2016
1 Person Made This Project!
- TarekM2 made it!
29 Comments
3 years ago
Please sent me code for epom that idont want led display
Reply 1 year ago
Did u solve the problem ?
3 years ago
hi, can you launched sensor fluxgate flc100 magnetometr with ardunio and conected to pc wiht bleuthos? thack you very much
Question 4 years ago
hi there, i have done similar project but my lcd going crazy showing weird character when i switch on ac supply..what should i do to overcome this problem..very thank you for all helps..
4 years ago
Good work....
Question 5 years ago
Hello, first of all, thank you for this interesting project. What could be the reason why the Bluetooth app doesn't make anything? I followed the instructions step by step, I don't know, is necessary to do something in the android app? Thanks a lot...
6 years ago
Interesting, thanks!
Reply 6 years ago
Thanks for feedback
Reply 6 years ago
Lcd can not show any character ,if upload the code . what i do ?
Reply 6 years ago
Add step 4,5 or 6 code.
Or
Contact me on whatsapp
+923065090466
6 years ago
I was able to do it with HC-05 Bluetooth. Renaming the Default Name of bluetooth would have helped in this (which i did ...research)..Thanks
Reply 6 years ago
yes you can use it hc-05 in slave mode
6 years ago
Great man
6 years ago
O Great bro thanks really amazing it is I will insha Allah try it after my test for nust
6 years ago
Good work bro ! Keep it up (Y)
6 years ago
Let's plan it on a large scale
6 years ago
Well done good job
Reply 6 years ago
Thanks man
6 years ago
Thanks
6 years ago
I do not believe the first one works because the <p></p> does not register with the arduino.