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!!

Digital Life 101 Challenge

Participated in the
Digital Life 101 Challenge