Voice controled home automation using Arduino over Bluetooth
REQUIRED PARTS
Arduino uno
jumpers
LCD 16x2
HC-05 Bluetooth module
Relay
Breadboard
Bulb Holder
The circuit
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 10
* LCD D5 pin to digital pin 9
* LCD D6 pin to digital pin 8
* LCD D7 pin to digital pin 7
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 7)
*green light digital pin 4
*blue light digital pin 3
*red light digital pin 2
*bulb/ light digital pin 5
*fan digital pin 6
*/
program code
#include<SoftwareSerial.h>
#include<LiquidCrystal.h>
SoftwareSerial bluetooth(0,1);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
short int red = 2,blue = 3,green = 4,light = 5, fan = 6;
String command;
void setup(){
for(int i =2;i<=6;i++)
pinMode(i,OUTPUT);
pinMode(temp_sensor,INPUT);
Serial.begin(9600);
bluetooth.begin(9600);
lcd.begin(16,2);
lcd.setCursor(5,0);
lcd.print("Welcome");
lcd.setCursor(4,1);
lcd.print("SREEKANTH");
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HI sir;");
}
void loop(){
while (bluetooth.available()){//Check if there is an available byte to read
delay(30); //Delay added to make thing stable
char c = bluetooth.read(); //Conduct a serial read
if (command == ""){
lcd.clear();
lcd.print("HI Sreekanth >>>");
}
command += c;
}
if (command.length() > 0) {
lcd.setCursor(1,1);
if(command == "red light on"||command == "red"){
digitalWrite(red,HIGH);
lcd.print("RED LIGHT ON");
Serial.println("Red light is on"); }
else if(command == "red light off" || command == "red light of"){
Serial.println("Red light is off");
digitalWrite(red,LOW);
lcd.println("RED LIGHT OFF");
}
else if(command == "blue light on" || command == "blue"){
lcd.print("BLUE LIGHT ON");
digitalWrite(blue,HIGH);
Serial.println("Blue light is on"); }
else if(command == "blue light off"){
lcd.print("BLUE LIGHT OFF");
digitalWrite(blue,LOW);
Serial.println("Blue light is off"); }
else if(command == "green light on" ||command == "green" || command == "Green"){
lcd.print("GREEN LIGHT ON");
digitalWrite(green,HIGH);
Serial.println("Green light is on"); }
else if(command == "green light off"){
lcd.print("GREEN LIGHT OFF");
digitalWrite(green,0);
Serial.println("Green light is off"); }
else if(command == "turn on the fan"){
lcd.print("FAN IS ON");
digitalWrite(fan,1);
Serial.println("Fan is on"); }
else if(command == "turn off the fan"){
lcd.print("FAN IS OFF");
digitalWrite(fan,0);
Serial.println("fFan is off"); }
else if(command == "light on"){
lcd.print("LIGHT IS ON");
digitalWrite(light,1);
Serial.println("Bulb is on"); }
else if(command == "light off"){
lcd.print("LIGHT IS OFF");
digitalWrite(light,0);
Serial.println("Bulb is off"); }
else if(command == "shut down"){
Serial.println("Shut down");
lcd.print("ALL DISABLED");
for(int x = 2;x<=6;x++)
digitalWrite(x,LOW);
}
command="";
}
}
Comments