Control your Arduino with voice commands using an Android smartphone! 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 smartphone and a HC-05 Bluetooth module.

The designer of the app did not include a sample code. I looked for alternatives in Google's PlayStore but none was as good as the app that I've found. Luckily, I was able to figure it out although it took me a while to program it. Sorry IOS users, this app isn't available in Apple's app store :/

How Does It Work?
Have you ever encountered Android's speech recognition? Yes android has one and you can use it to control your Arduino, via Bluetooth. The App works by pressing the mic button, then the it will wait for you to say a command. The app will then display the word's that you've stated and will send data strings for the Arduino to process.

Home Automation System (on July 4, 2014):
A month from now/ I'll be releasing a highly sophisticated home automation + security system. It's my biggest project ever! Our current agenda is to program a better smartphone app that work's like Siri (talks back) and sends strings (data types) to the Arduino via bluetooth. If you want to take a sneak peek of the project and it's concept, kindly skip to the last step. The prototype that I'm working on now is composed of a network of wireless switch boxes that connects to a main control panel via WiFi/ Bluetooth.

Here's A Quick Video Demo:

Step 1: Parts & Materials

If your having trouble in finding them, I'm sure RadioShack has all of them. If you want to buy online try searching on Amazon or DealExtreme.

Thing that you'll need:
- 5 LED Indicators (the color of your choice)
- Arduino UNO (a clone works fine)
- HC-05 Serial Bluetooth Module
- Solderless Breadboard
- Jumper Cables

Step 2: Assemble the Mini Bluetooth Shield

My JY-MCU (DX Bluetooth Module) is still installed on my robots, what I have right now is the bare HC-05 module.

As we all know, the HC-05 doesn't come with a PCB. Soldering wires, directly to the metal conductors, isn't a good idea since the conductors could chip off anytime. As a solution, you can cut a fraction of perf-board then mount the HC-05 on it. I mistakenly connected my LED indicator on a blank (N/A) pin so mine doesn't work.
Too lazy to assemble a Bluetooth shield? DX.com has a ready made version (click here). I've used the DX Bluetooth module on my robots, it's tested and it's 100% ok! You can visit Bluetooth related projects (Bluetooth Sumobot and Bluetooth FPV Rover) as reference.

Step 3: Connect the Bluetooth Module

Grab some jumper cables and power the Bluetooth module with 3.3 volts. Remember, the bare HC-05 run on 3.3v and not on 5v. On the other hand, the JY-MCU has a built in regulator, it can run on a 5v line.

Now connect the RX (pin #0) of the Arduino to the TX pin of the Bluetooth module and the TX (pin #1) of the Arduino to the RX pin of the Bluetooth module. (refer to the image above)

Step 4: Connect the LEDs

Connect the positive leads of each LED on pins # 2,3,4,5,6 of the Arduino. The negative leads of each LED goes to the negative rail of the breadboard. The negative rail of the breadboard goes to the Arduino's ground.

Step 5: Programming the Arduino

Understanding The App: 
Before you program the arduino, you must first learn how the app works. The app work by recognizing your voice command, it will then display the words that you've spoken then sending data/ strings to the arduino via bluetooth. What's a string? A string is like a word, you can make conditional statements out of it [ex: if (voice == "*computer on") {// turn Pin #2 on} ]. The "voice" is your string, "==" is your condition (means equal to), "*computer on" is your command and the code inside the curly-braces "{ }" are the codes to be executed once your string matches the command condition. 

What's the format of the string? How does it know when the next command kicks in? How does it differentiate a set of words from a new command? The app sends strings in this format *command#, the asterisk (*) indicates the start of a new command and the hash-tag (#) indicates the end of a command. I was able to remove the hash-tag (#) after each word in the conditional statement was not able to remove the asterisk (*). You'll need to start your command condition with an asterisk otherwise the sketch will not work. 

How Can I Change The Commands?
You can see that the "*TV on" is highlighted from the image above. If you want to change the command to ,humm let's say "open garage door", you can replace the "*TV on" with "*open garage door". Always remember to start the command with an asterisk.

//Coded By: Angelo Casimiro (4/27/14)
//Voice Activated Arduino (Bluetooth + Android)
//Feel free to modify it but remember to give credit

String voice;
led1 = 2, //Connect LED 1 To Pin #2
led2 = 3, //Connect LED 2 To Pin #3
led3 = 4, //Connect LED 3 To Pin #4
led4 = 5, //Connect LED 4 To Pin #5
led5 = 6; //Connect LED 5 To Pin #6
//--------------------------Call A Function-------------------------------// 
void allon(){
     digitalWrite(led1, HIGH);
     digitalWrite(led2, HIGH);
     digitalWrite(led3, HIGH);
     digitalWrite(led4, HIGH);
     digitalWrite(led5, HIGH);
void alloff(){
     digitalWrite(led1, LOW);
     digitalWrite(led2, LOW);
     digitalWrite(led3, LOW);
     digitalWrite(led4, LOW);
     digitalWrite(led5, LOW);
void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
void loop() {
  while (Serial.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable
  char c = Serial.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  if (voice.length() > 0) {
  //----------Control Multiple Pins/ LEDs----------// 
       if(voice == "*all on") {allon();}  //Turn Off All Pins (Call Function)
  else if(voice == "*all off"){alloff();} //Turn On  All Pins (Call Function)
  //----------Turn On One-By-One----------//
  else if(voice == "*TV on") {digitalWrite(led1, HIGH);}
  else if(voice == "*fan on") {digitalWrite(led2, HIGH);}
  else if(voice == "*computer on") {digitalWrite(led3, HIGH);}
  else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);}
  else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);}
  //----------Turn Off One-By-One----------//
  else if(voice == "*TV off") {digitalWrite(led1, LOW);}
  else if(voice == "*fan off") {digitalWrite(led2, LOW);}
  else if(voice == "*computer off") {digitalWrite(led3, LOW);}
  else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);}
  else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);}
voice="";}} //Reset the variable after initiating

Step 6: Learn to Use the App

Download The Free App Here: Android Meets Robots : Voice 

5 Simple Steps:
1st.)  Download the app from Google PlayStore
2nd.) Tap on options menu then select "Connect Robot"
3rd.)  Click on your BT-Module (in my case it's the HC-05)
4th.)  Wait until it says Connected to BT-Module (HC-05)
5th.) Tap on the mic icon and state your command!

Here's A Quick Demo Video:

Step 7: Next Project: Highly-Sophisticated Home Automation (Network)

Here's a drawing of what to expect on my next Arduino project!

Sorry for the terrible doodle :)
<p>that's works thanks.</p><p>instructable</p>
i made small modification. But for this error
*But got this error
<p>We built a circuit in our project. As a result, we showed the LCD on the screen. How can I send this text to the android mobile phone? And how can I read this text that I sent out by voice? I used genuino 101.</p>
<p>hello,,,,, can you sent me android program in (aia) ?</p>
Take from playstore
<p>Why do we need the PCB design on HC-05 module? And how can I do this? Please guide me. And I can not connect my module with my galaxy grand 2 set. How can I connect?</p>
You can use directly hc-06
<p>why you are asking money for pdf </p>
He is not asking. You can only download pdf if you take instructors prime membership
<p>how to download pdf?</p>
<p>good job</p>
<p>Hello </p><p>Can I put this instructable in my site, I will mention your name</p>
<p>hello,,,,, can you sent me android program in (aia) ?</p>
if we change the command in the arduino ino file while programming the arduino uno R3, eg:- instead of 'bathroom lights on' we will write 'lights on' then is there any need to change anything in the android software?<br><br>i am new to programming and electronics...so asking.....as i am interested to make it.
<p>sir i want to connect an lcd interface 16x2 with this project which will show the status that which light is on at certain instant of time.Thus inorder to do so i need modified version of this code...so can u plz provide me that code...its my project and i haveno time left so can u do this favour to me as early as possible?</p>
<p>PLEASE tell me how to download it completely...i am waiting for an answer</p>
<p>Hi! This is a very nice project to make, and thank you for making a tutorial. However, I want to add an AI function that you can talk to, like Siri for example. Is there any way I can edit the source code of the mobile app?</p><p>Thanks!</p>
<p>Hi</p><p>I want a version of this android app that is constantly listening for voicecommands so that i dont need to press the button every time. do you know of an alternate app/sourcecode for this one so i can change it myself?</p>
<p>hi, it is a great project and it is related to my final year project!<br>unfortunately it is not working when i am using samsung galaxy s4 as the app keep cannot recognise my voice and showing try again.....<br>i have tested the voice recognition function of my phone and it is working...<br>anyone can help ?? </p>
<p>I made a bluetooth activated relay switch using this tutorial. Great job! I wish I can get it to power by using the same switch and not depending on batteries or a usb cable. Thanks for the guide. </p>
<p>Works perfectly. I have plans to use this in my living room.</p>
Ok sir thanks alot
<p>hey dude can u give me the sample codes? I have problem with error in my codes and what code language do you use????? thanks.:)</p>
Hello RaylinP,<br>The code is edited in and uploaded from the Arduino software. Also known as the Arduino IDE (integrated development environment) and the video and the Instructable article is where I found the information. I did manage to add two more relays to my copy of the Arduino software (sketch) for a total of four. <br>Here is the Instructable: <br>https://www.instructables.com/id/Arduino-Home-Automation-Bluetooth/<br>and his Youtube video:<br>https://youtu.be/ecPbeIkFHxQ?list=PLLS_feeVWGq-LMUirPsmULI0Tl4721JLe<br>So if I can help you with anything let me know.<br>David Connolly,<br>volthaus lab
<p>My voice controlled Arduino/4 relay sketch is at:</p><p>http://volthauslab.com/sketchs/FourRelayVoiceControl/HomeAutomationVH4.ino</p>
<p>Sir , David Im so thankful for considering my question and giving some of your time just to reply me, I greatly appreciate it, :) and can I ask 1 more thing? when you try with the code of Sir. Angelo Casimero does the code work? or having some error? thank you very much! :)</p><p><br><br>credits to Sir Angelo Casimero :)<br>String voice;</p><p>int<br>led1 = 2, //Connect LED 1 To Pin #2<br>led2 = 3, //Connect LED 2 To Pin #3<br>led3 = 4, //Connect LED 3 To Pin #4<br>led4 = 5, //Connect LED 4 To Pin #5<br>led5 = 6; //Connect LED 5 To Pin #6<br>//--------------------------Call A Function-------------------------------// <br>void allon(){<br>digitalWrite(led1, HIGH);<br>digitalWrite(led2, HIGH);<br>digitalWrite(led3, HIGH);<br>digitalWrite(led4, HIGH);<br>digitalWrite(led5, HIGH);<br>}<br>void alloff(){<br>digitalWrite(led1, LOW);<br>digitalWrite(led2, LOW);<br>digitalWrite(led3, LOW);<br>digitalWrite(led4, LOW);<br>digitalWrite(led5, LOW);<br>}<br>//-----------------------------------------------------------------------// <br>void setup() {<br>Serial.begin(9600);<br>pinMode(led1, OUTPUT);<br>pinMode(led2, OUTPUT);<br>pinMode(led3, OUTPUT);<br>pinMode(led4, OUTPUT);<br>pinMode(led5, OUTPUT);<br>}<br>//-----------------------------------------------------------------------// <br>void loop() {<br>while (Serial.available()){ //Check if there is an available byte to read<br>delay(10); //Delay added to make thing stable<br>char c = Serial.read(); //Conduct a serial read<br>if (c == '#') {break;} //Exit the loop when the # is detected after the word<br>voice += c; //Shorthand for voice = voice + c<br>} <br>if (voice.length() &gt; 0) {<br>Serial.println(voice);<br>//-----------------------------------------------------------------------// <br>//----------Control Multiple Pins/ LEDs----------// <br>if(voice == &quot;*all on&quot;) {allon();} //Turn Off All Pins (Call Function)<br>else if(voice == &quot;*all off&quot;){alloff();} //Turn On All Pins (Call Function)<br><br>//----------Turn On One-By-One----------//<br>else if(voice == &quot;*TV on&quot;) {digitalWrite(led1, HIGH);}<br>else if(voice == &quot;*fan on&quot;) {digitalWrite(led2, HIGH);}<br>else if(voice == &quot;*computer on&quot;) {digitalWrite(led3, HIGH);}<br>else if(voice == &quot;*bedroom lights on&quot;) {digitalWrite(led4, HIGH);}<br>else if(voice == &quot;*bathroom lights on&quot;) {digitalWrite(led5, HIGH);}<br>//----------Turn Off One-By-One----------//<br>else if(voice == &quot;*TV off&quot;) {digitalWrite(led1, LOW);}<br>else if(voice == &quot;*fan off&quot;) {digitalWrite(led2, LOW);}<br>else if(voice == &quot;*computer off&quot;) {digitalWrite(led3, LOW);}<br>else if(voice == &quot;*bedroom lights off&quot;) {digitalWrite(led4, LOW);}<br>else if(voice == &quot;*bathroom lights off&quot;) {digitalWrite(led5, LOW);}<br>//-----------------------------------------------------------------------// <br>voice=&quot;&quot;;}} //Reset the variable after initiating</p>
<p>Yes the code is fine. You'll want to use Tools/Auto Format if you copy and paste the code from this page I think. Sometimes copy and pasting the code into a webpage can make a negative change in the code. Better yet download the zip and use that.</p>
<p>Hi sir I have one more question. can I use any bluetooth serial? hope ill get your reply tnx :)</p>
<p>I have the best results using the HC-05 module. It seems to do a better job of maintaining the connection. Often when I use HC-06 I have to keep re-connecting. You are very welcome my friend.. I'm always glad to help someone who is interested in electronics. Good luck.</p>
<p> sir I used voltage divider for rx and tx still the LEDs aren't responding as per my commands.. I changed the program and added a else statement in the end what I noticed is when i speak directly else statement is getting executed not the if else statements. Am not understanding whether it's the problem with my program or module???</p>
<p>I have some interesting information. I had this worling perfectly and decided to build a second system. All the same parts and code. Uploaded code and did not get LEDS to blink. Uploaded code (same code as before) to the working system and now it no longer works. I will be trying some other options but I suggest trying it with other parts and observing results.</p>
<p>Thank you so Much sir David :) hope I can return the favor, again Thank you ! :)</p>
<p>Thank you so much sir David! :) Im so grateful :) thank you for considering my questions and making use of your time just to answer me .again thank you :) </p>
<p>dude did you rectify the problem??.. If so plz plz guide me, I tried everything perfectly my voice is also recognised on the arm voice application (after i speak text appears on the app) but leds are not blinking as per the commands. plz plz help me to solve this problem...</p>
<p>I want to help you dude but I dont know how. maybe you can ask sir David of Volthaus Elecs. Lab</p>
Tysm raylinP for replying so quickly.. Can you tell me how can i contact DAVID sir ??
<p>Sir I tried everything perfectly my voice is also recognised on the arm voice application (after i speak text appears on the app) but leds are not blinking as per the commands. plz plz help me to solve this problem...</p>
<p>When you encounter problems you often learn even more.. You now need to double check and confirm you have connected the positive leads of each LED on digital pins # 2,3,4,5,6 of the Arduino. (Not the Analog pins) The negative leads of each LED goes to 220 ohm resistors and then to the negative rail of the breadboard. If you do not put a resistor between each LED and the ground you will probably ruin the LED. Check the LED and make sure it is good and lights. You could use the 5V output pin on the Arduino.. Maybe post a picture of your setup? I hope this helps, if not we will keep working on it until it does. Do not despair, this is the fun part Sachin008.</p>
Thank you sir for considering my question. Sir I have connected LEDs and Bluetooth module exactly how you said still my LEDs are glowing as per my command
<p>The Bluetooth modules HC-05 and 06 can be powered by 5VDC however the signals being sent from the module to the Arduino and the signals back from the Arduino to the Bluetooth module should be 3.3VDC. My modules can handle a 5VDC signal but I'm sure some can not so I suggest you add a level shifter to make sure the 5VDC signal the Arduino sends to the Bluetooth module is 3.3VDC when it arrives to the Bluetooth. Also it will change the 3.3VDC signal being sent from the Bluetooth to 5VDC before it reaches the Arduino.</p><p>Here is my Instructable on Level Shifters:</p><p><a href="https://www.instructables.com/id/Level-Shifters/" rel="nofollow">https://www.instructables.com/id/Level-Shifters/</a></p>
Sir i have used voltage divider at the rx pin of the module . i will send you the pic of the entire setup.
<p>Well try a separate voltage divider for both TX and RX. </p>
<p>Well try a separate voltage divider for both TX and RX. </p>
My Bluetooth hc 05 has 6 pins is that the cause of the problem??
<p>Also most importantly confirm the RX pin on the Bluetooth is connected to the TX pin (Digital Pin #1 on the Arduino) and the TX pin on the Bluetooth is connected to the Digital 0 (zero) pin on the Arduino</p>
<p>VERY COOL! Great directions...Many Thanks. All worked straight away. Was a fun little project for a Sunday Afternoon.</p>
<p>thank u for your excellent work. can u explain why a variable char c used. can we use directly string voice as Serial.read()?</p>
Can you tell me the logic behind this project?
Could you please tell

About This Instructable




Bio: Hi I'm Angelo! I am a 18 y/o college sophomore taking my majors in BS-ECE at the DLSU. I use my course as ... More »
More by ASCAS:Build A Bluetooth Boombox Speaker (from scratch)  DIY Life-Size Phone Controlled BB8 Droid Rig A Car Horn To Your Alarmclock! 
Add instructable to: