Introduction: Voice to Arduino: Control LEDs Using MIT Speech Recognizer

Hello, everybody!!! It has been some time I had not updated my post here. Today I would like to share with you guys an experiment I made. I am going to control LEDs using MIT app inventor speech recognizer. Oh before I forget, I had also started a blog where I post some other Arduino Experiments. Feel free to visit to my blog at

halim930112.blogspot.com

Ok now, let's see what is needed to accomplish this experiment.

Step 1: Items Needed

The Items needed for this experiment are as follows:

Hardware:

1.Arduino UNO

2.LED x 4

3.Resistors x4 (recommended but not used for this experiment)

4.Male to male to jumper

5.Android Smartphone

6.HC-06

Software

1.Arduino IDE

2.MIT app inventor

Well, that wraps up for the items needed. On to the next step!!!!

Step 2: Circuit Assembly!!!!

Well, the circuit assembly is not difficult. The circuit consists only of LEDs, resistors, HC-06 and Arduino. The long "leg" of the LED will be connected to the pinouts while the shorter "led" will be connected to the GND. For the HC-06, the VCC is connected to 5V, GND to GND, RX of HC-06 to Arduino TX, while TX of HC-06 to Arduino RX. From here I will divide the codes into two parts, MIT and Arduino. First let's see the MIT code.

Step 3: MIT App Inventor Code Block

The important aspect of this app is that it implements the Speech recognizer function alongside the Clock and the Bluetooth client function. A google Speech recognizer(you need to be connected to the internet) will be activated when the speak button is pressed. Whatever spoken will be shown in the label "What do you speak" and be sent to Arduino. The arduino will do the rest of the processing.

Step 4: Arduino Code

The Arduino code is pretty simple as shown below:

int led1 = 8;
int led2 = 9;

int led3 = 10;

int led4 = 11;//change led position accordingly

int value = 0;//initial serial read value

void setup()

{ Serial.begin(9600);//this is important. the baud rate between arduino bluetooth and smartphone

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);

}

void loop()

{

while(Serial.available())

{//if serial reading is available

delay(1000);//delay for a second, avoid overloading

value = Serial.read(); //value = serial value(led value)

Serial.print(value);//print the serial value

Serial.println();

if (value == 1)//the value which corresponds the MIT appinventor 2 byte sent. change accordingly to your own value here and MIT appinventor 2 code block

{

digitalWrite(led1,HIGH);

digitalWrite(led2,LOW);

digitalWrite(led3,LOW);

digitalWrite(led4,LOW);

}

if (value == 2)

{

digitalWrite(led1,HIGH);

digitalWrite(led2,HIGH);

digitalWrite(led3,LOW);

digitalWrite(led4,LOW);

}

if (value == 3)

{

digitalWrite(led1,HIGH);

digitalWrite(led2,HIGH);

digitalWrite(led3,HIGH);

digitalWrite(led4,LOW);

}

if (value == 4)

{

digitalWrite(led1,HIGH);

digitalWrite(led2,HIGH);

digitalWrite(led3,HIGH);

digitalWrite(led4,HIGH);

}

}

}

Step 5: TEST!TEST!TEST!

Upload the Arduino code to Arduino UNO board (remember to unplug the TX and RX while uploading and plug in back after uploading). Download the apk file from MIT and install it in the android smartphone and test the experiment. The sample video of this experiment can be seen in the link below:

Well,that's all from me. Hope to see you guys again in near future!!

Comments

author
jahangeerq1 made it!(author)2016-07-09

if i wanted to send words what alteration would need to be made in the arduino code

author
Murray+Locksmith made it!(author)2016-03-03

WOW !!! great

author
SalbaheJim made it!(author)2016-02-26

When I hit reply it didn't show your latest comment: "Hi, I think I kind of did what you were asking. Safe to say it works!!! You can see it in my blog:http://halim930112.blogspot.my/"

I checked it out and it's brilliantly simple. Start adding more and more functionality and string parsing and you could make this so flexible and dynamic!

author
Alanzheng made it!(author)2016-02-26

Does Hc-06 work with iPhone?

author
halim930112 made it!(author)2016-02-26

I think HC-06 is not supported with iPhone as iPhone does not have Serial Protocol over Bluetooth

author
SalbaheJim made it!(author)2016-02-23

Can you only send it integer values? What about strings?

I wonder how hard it would be to embed the android phone into, for example, a virtual presence device and give it verbal control commands like, "rotate left 90 degrees," "move forward three meters," "power down," "report battery status," etc...

author
halim930112 made it!(author)2016-02-23

In my opinion, i think it could be done. In this experiment, I had initialized the values as integer, maybe ( I had not try it yet) if we change the initialization into string/text, we might be able to send text commands. Thanks for the comment though, you gave me an Idea on what to do next.

author
SalbaheJim made it!(author)2016-02-23

Oh, I really look forward to seeing what you come up with!

author
halim930112 made it!(author)2016-02-26

Hi, I think I kind of did what you were asking. Safe to say it works!!! You can see it in my blog:

http://halim930112.blogspot.my/

author
diy_bloke made it!(author)2016-02-22

interesting. I have used the voice recognition on MIT app inventor as well. But I dont think you need to be connected to the internet while using the Speech recognizer in the created app. So I tried my app with the WiFi switched off and that works just as fine.
Anyway, I used the same voice recognition as you did so I am sure your app also works without being connected to the internet as it picks up the speechrecognizer on your phone

speech.png
author
halim930112 made it!(author)2016-02-22

Oh, I see. I thought the speech recognizer needs to be connected to the internet to be functional properly. Anyway, thank you very much for the information

author
diy_bloke made it!(author)2016-02-22

Glad to be of help. Indeed, it is all local on yr smartphone

author
halim930112 made it!(author)2016-02-21

the app for this experiment can be found here:

ai2.appinventor.mit.edu/?galleryId=6018303708889088