Automation
Automation
HOME AUTOMATION
USING ARDUINO + BLUETOOTH + ANDROID
Overview
Control your Arduino with voice commands using an Android phone! Before we make a
voice activated home automation system, we must first learn the basic principles of the
experiment. This guide will let you command the Arduino using your Android phone and
a HC-05 Bluetooth module.
The system is based on the popular Arduino development platform and the inexpensive
HC-05 or HC-06 Bluetooth module. It uses android application (AMR Voice) as the
voice recognition system.
The Hardware
Programming Tools
If you dont have PC or Laptop you can used tablet Android phone as
alternative and it works fine. Just install the application Arduino IDE at play
store.
Things you need are:
1. USB cable
2. PC or Tab
3. Arduino sketch file (voicecontrol.ino)
Open the sketch file and compile.
Now the wiring diagram as shown in the image are pretty much self explanatory even
for those newbies in electronics, just follow the instruction and load the code.
PINS CONFIGURATION:
Warning!
Please note that HC-06 Bluetooth module only require 3.3v to operate. Do not use the
5v or 6v because the module will burn-up and fry your device.
Photo shows the wire connection between VCC and GND going to the Bluetooth
module.
The photo shows the connection between (RX) and (TX) going to the Bluetooth module
as well and the PIN1 and PIN2 going to the LED (red and green).
The code
/*
-----------------------------------------------------------------------russelGuide
Voice Activated Controller
Arduino Bohol
-----------------------------------------------------------------------*/
String voice;
#define led1 2 //Connect led1 to pin 2
#define led2 3 //Connect led2 to pin 3
#define led3 4 //Connect led1 to pin 4
#define led4 5 //Connect led2 to pin 5
#define led5 6 //Connect led1 to pin 6
void setup()
{
Serial.begin(9600);
//Set rate for communicating with serial
pinMode(led1, OUTPUT);
//Set led1 as an output
pinMode(led2, OUTPUT);
//Set led2 as an output
pinMode(led3, OUTPUT);
//Set led3 as an output
pinMode(led4, OUTPUT);
//Set led4 as an output
pinMode(led5, OUTPUT);
//Set led5 as an output
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
void loop()
{
while(Serial.available()) //Check if there are available bytes to read
{
delay(10);
//Delay to make it stable
char c = Serial.read(); //Conduct a serial read
if (c == '#'){
break;
//Stop the loop once # is detected after a word
}
voice += c;
//Means voice = voice + c
}
if (voice.length() >0)
{
Serial.println(voice);
if(voice == "*all on")
{allon();}