Home Automation With Arduino, Buttons ,LCD ,EEPROM AND Smart Phone
by awaiskhawar in Circuits > Arduino
63845 Views, 553 Favorites, 0 Comments
Home Automation With Arduino, Buttons ,LCD ,EEPROM AND Smart Phone
Now we can control full home with smart Phone
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
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
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>
Downloads
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>
Downloads
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>
Downloads
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>
Downloads
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