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 creditString voice;intled1 = 2, //Connect LED 1 To Pin #2led2 = 3, //Connect LED 2 To Pin #3led3 = 4, //Connect LED 3 To Pin #4led4 = 5, //Connect LED 4 To Pin #5led5 = 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() {Serial.begin(9600);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 readdelay(10); //Delay added to make thing stablechar c = Serial.read(); //Conduct a serial readif (c == '#') {break;} //Exit the loop when the # is detected after the wordvoice += c; //Shorthand for voice = voice + cif (voice.length() > 0) {Serial.println(voice);//-----------------------------------------------------------------------////----------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