Arduino voice control of leds using Bluetooth module

Arduino voice control of leds using Bluetooth module
Arduino voice control of devices can be done in a number of ways using voice recognition modules for example EasyVR Shield 3.0, ELECHOUSE Voice Recognition Module V3, Tigal SmartVR Voice Recognition Board, Grove – Speech Recognizer and other modules. These devices can store simple commands in different languages that can be used to run basic controls.
These modules are very efficient but are a bit expensive and as such for simple projects we can use our smart phones.In this tutorialI demonstrate how you can use your smart phone for voice control of leds with Arduino.
We just need an Arduino UNO to serially communicate with HC-06 or HC-05 Bluetooth module and a smartphone to send voice command to Bluetooth module. For receiving voice commands we use an Android app which you can download from play store.

Connections for the HC-05 Bluetooth module.

HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Its communication is via serial communication which makes an easy way to interface with microcontrollers. HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use neither receiving nor transmitting data.
hc-05 module pin out
  • VCC – to VCC of Arduino.
  • GND – to GND of Arduino.
  • RX – to digital pin 0(TX pin) of Arduino.
  • TX – to digital pin 1(RX pin) of Arduino.
  • NOTE: While uploading the code to the Arduino UNO disconnect the Rx and Tx pins .Connect RX and TX pins after uploading the code.

    Connecting the bluetooth module to Arduino.

    voice control arduino 11
    voice control arduino sketch

    Code for Arduino voice control.

    For voice control using Arduino an important library that is needed is the SoftwareSerial.h Library. This library can be downloaded from here. Make sure this Library is installed in the Arduino IDE data base.
    #include <SoftwareSerial.h>
    SoftwareSerial BT(0,1); //RX, TX respetively
    String voice;
    int RED = 9; // Red LED at pin 9
    int BLUE = 11; // Blue LED at pin 11
    int GREEN = 10; //Green LED at pin 10
    void RedOn(){ // Red LED on, others off
    digitalWrite (RED, HIGH);
    digitalWrite (GREEN, LOW);
    digitalWrite (BLUE, LOW);
    }
    void RedOff(){ // Red LED off, others on
    digitalWrite (RED, LOW);
    digitalWrite (GREEN, HIGH);
    digitalWrite (BLUE, HIGH);
    }
    void GreenOn(){
    digitalWrite (GREEN, HIGH);
    digitalWrite (RED, LOW);
    digitalWrite (BLUE, LOW);
    }
    void GreenOff(){
    digitalWrite (GREEN, LOW);
    digitalWrite (RED, HIGH);
    digitalWrite (BLUE, HIGH);
    }
    void BlueOn(){
    digitalWrite (BLUE, HIGH);
    digitalWrite (GREEN, LOW);
    digitalWrite (RED, LOW);
    }
    void BlueOff(){
    digitalWrite (BLUE, LOW);
    digitalWrite (GREEN, HIGH);
    digitalWrite (RED, HIGH);
    }void allon() {
    digitalWrite (RED, HIGH);
    digitalWrite (GREEN, HIGH);
    digitalWrite (BLUE, HIGH);
    }
    void alloff() {
    digitalWrite (RED, LOW);
    digitalWrite (GREEN, LOW);
    digitalWrite (BLUE, LOW);
    }
    void setup() {
    BT.begin(9600);
    Serial.begin(9600);
    pinMode(RED, OUTPUT);
    pinMode(GREEN, OUTPUT);
    pinMode(BLUE, OUTPUT);
    }
    void loop() {
    while(BT.available()) {
    delay(10);
    char c=BT.read();
    if(c=='#')
    {break; }
    voice += c;
    }
    if (voice.length() > 0) {
    Serial.println(voice);
    if (voice == "welcome" || voice == "on") // if the voice says "welcome", all the LEDs turn on
    {
    allon() ;
    }
    else if (voice == "goodbye" || voice=="switch off all") // If the voice says"goodbye", all the LEDs turn off
    {
    alloff() ;
    }
    else if(voice =="red color" || voice =="red on"){
    RedOn();
    }
    else if(voice =="red color off"){
    RedOff();
    }
    else if(voice =="blue " || voice =="blue on"){
    BlueOn();
    }
    else if(voice =="switch of blue"){
    BlueOff();
    }
    else if(voice =="green color" || voice =="green on"){
    GreenOn();
    }
    else if(voice =="switch of green"){
    GreenOff();
    }
    voice="";
    }
    }
    

    Android App used

    For this project we use Android Voice Control app which is got from the Google play store. This Application enables us to connect the phone and the Arduino board through bluetooth and to be able to interprete the voice commands using Google speech recognition service.
    The App can be downloaded from here.

    One thought on “Arduino voice control of leds using Bluetooth module

    1. absolutely brilliant !

      didnt even occur to me it could be this simple !!!

      well done and a MASSIVE round of thanks for sharing the schematics and the code, keeping with the awesomeness that is open-source !

      keep up the great inspiring tutorials !!

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Back to top