Danny van den Brande
Published © CC BY-SA

Arduino - Home Control With Bluetooth And Voice

Simple Home control device using Bluetooth and Android.

BeginnerProtip1 hour1,739
Arduino - Home Control With Bluetooth And Voice

Things used in this project

Story

Read more

Schematics

Schematic

Code

BLUETOOTH_voice_home_control.ino

Arduino
Voice control for 2 relays. You can add more relays if needed.
This code only controls 2 lamps or devices.
/*
Author: Danny van den Brande, ArduinoSensors.nl, BlueCore Tech.
Voice control for 2 relays. You can add more relays if needed.
This code only controls 2 lamps or devices. Just copy/paste the "COPY/PASTE SECTION" that i made.
 */

String voice;

#define relay1 2    
#define relay2 3 // You can add more relays if needed like this.
//#define relay3 4 // Just uncomment these lines to use more relays 
//#define relay4 5 // i set up 3 extra for you.  

void setup()
{
  Serial.begin(9600);            
  pinMode(relay1, OUTPUT);  
  pinMode(relay2, OUTPUT);//uncomment these lines when using more relays.
//  pinMode(relay3, OUTPUT);
//  pinMode(relay4, OUTPUT);     
}
void loop()
{
  while(Serial.available())   
  {
    delay(10);                 
    char c = Serial.read();   
    if (c == '#'){
      break;                   
    }
    voice += c;                //Means voice = voice + c
  }
    if (voice.length() >0)
    {
      Serial.println(voice); 
      if(voice == "*all on"){ //dont remove the *
        digitalWrite(relay1, HIGH);// This will turn on everything.
        digitalWrite(relay2, HIGH);
//        digitalWrite(relay3, HIGH);
//        digitalWrite(relay4, HIGH);
      }               
      else if(voice == "*all off"){// This will turn off everything.
        digitalWrite(relay1, LOW);
        digitalWrite(relay2, LOW);
//        digitalWrite(relay3, LOW);
//        digitalWrite(relay4, LOW);
      }               
      else if(voice == "*livingroom on"){ //you can fill in whatever you want.
        digitalWrite(relay1, HIGH);
      }
      else if(voice == "*livingroom off"){
        digitalWrite(relay1, LOW);
      }
      // COPY/PASTE SECTION BEGIN
      else if(voice == "*kitchen on"){    //paste from here to add more relays.
        digitalWrite(relay2, HIGH);
      }
      else if(voice == "*kitchen off"){
        digitalWrite(relay2, LOW);
      }                                   //Paste to here to add more relays.
      // COPY/PASTE SECTION END

      voice="";
    }
}

Credits

Danny van den Brande

Danny van den Brande

36 projects • 108 followers
"Hello world."

Comments