Control LEDs with Voice Command

Control LEDs with Voice Command


This is a very basic project for controlling LED (Red) using voice control. To accomplish this we have used the Bluetooth HC-05 module and android apps are available on the play store. LEDs will be On/Off on your voice command.


Procedure:-
  1. Make the connections as shown in the connection image. Don’t connect the RX & TX pins WHILE/BEFORE  uploading the code!
  2. Copy the code given below.
  3. Download any app called BT Voice Control.
  4. Open the app (It will automatically turn on the device’s Bluetooth). Go to options. Click on “Connect”. Choose the device – HC 05.
  5. When you are connecting to the Bluetooth module for the first time, it will ask you for the password. Enter 0000 OR 1234.
  6.  When the device gets successfully paired with the sensor, the LED lights on the sensor will start blinking at a slower rate than usual.
  7. DONE. Copy the code given below & test it out!

Source Code:-

String voice;
#define RED 8

void setup() {
  Serial.begin(9600);
  pinMode(RED,OUTPUT);
}
 

void RedOn(){
digitalWrite (RED, HIGH);
}
void RedOff(){
digitalWrite (RED, LOW);
}

 
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) {
    Serial.println(voice);
//-----------------------------------------------------------------------//   
  //----------Control Multiple Pins/ LEDs----------// 
   if(voice =="red" || voice =="red on"){
        RedOn();
    }
    else if(voice =="red off"){
        RedOff();
    }

voice=""; //Reset the variable after initiating
}
}



Connections:-

Bluetooth:-     Arduino UNO:-
  RxD       ==>          TxD
  TxD       ==>          RxD
  Vcc        ==>          3.3V
  Gnd       ==>          Gnd

Comments

Popular posts from this blog

LCD Interfacing with 8051 Microcontroller

Serial Interrupt Programming in 8051 Microcontroller

Interfacing LED with 8051 Microcontroller in Assembly