VOICE CONTROL HC 05 RELAY

HI.
I AM ANTONIS AND I HAVE PROBLEM WITH MY ARDUINO. I HAVE ARDUINO UNO,HC 05,AND RELAY.
I CONNECTED CORRECTLY,I TOOK READY CODE BUT NOT WORK.
CAN YOU WRITE ME SOMEONE A CODE FOR THIS.
MY TARGET IS TO TALK TO HC 05 AND THIS TO SEND SIGNAL THE RELAY FOR EXAMPLE ...LIGHT ON...LIGHT OF

THANK YOU

VOICE CONTROL HC 05 RELAY
MY TARGET IS TO TALK TO HC 05 AND THIS TO SEND SIGNAL THE RELAY FOR EXAMPLE ...LIGHT ON...LIGHT OFF
I TOOK READY CODE BUT NOT WORK.

Why are you posting all in capital letters?

Please post a link to the tutorial you are following and the code you are using. Post your code using the code tags as explained in item 7 of "How to use this Forum" https://forum.arduino.cc/index.php?topic=148850.0

If "ready code" worked for the tutorial writer but not for you, how are you certain that you are connected correctly? Have you paired with and communicated with the HC05 using a bluetooth serial terminal app?

Can you write the code which turns the relay on and off using input from the Serial Monitor?

I CONNECTED HC 05 TX 11 RX 10 AND MY RELAY PIN 4 AND ALSO I GAVE 5V AND GROUND THE RELAY AND HC 05.AFTER I OPENNED AMR VOICE I CONNECTED MY BLUETOOTH WITH MY HC 05 BUT NOT WORKING...I WORK ONLY COMMAND LIGHT ON LIGHT OFF

#include<SoftwareSerial.h>
#include<Servo.h>
#define RELAY 4       //initialize digital pin 4 to relay
SoftwareSerial  BT(11, 10); //initialize bluetooth TX and RX to pin11 and pin10 of  
                                                    arduino
String voice;
Servo myservo;   //create servo object to control a servo
int pos = 90;  // variable to store the servo position
void setup()
{
  BT.begin(9600);
  Serial.begin(9600);
  pinMode(2, OUTPUT);  // initialize digital pin 2 as an output.
  myservo.attach(3);  // attaches the servo on pin 3 to the servo object
  pinMode(RELAY, OUTPUT);
  pinMode(5, OUTPUT); // intialize digital pin 5 to one end of DC motor
  pinMode(6, OUTPUT); // intialize digital pin 6 to one end of DC motor
}
void loop()
{
  while (BT.available())      //Check if there is an available byte to read
  {
    delay(10);              //Delay added to make thing stable
    char c = BT.read();
    if (c == '#')
    {
      break;             //Exit the loop when the # is detected after the word
    }
    voice += c;           //build the string
  }
  if (voice.length() > 0)
  {
    Serial.println(voice);
    if (voice == "*TV on")
    {
      digitalWrite(2, HIGH);   // led turn on
    }
    else if (voice == "*TV off")
    {
      digitalWrite(2, LOW);   // led turn off
    }
    else if (voice == "*door open")
     {  
      for (pos = 90; pos <= 180; pos++) // goes from 0 degrees to 90 degrees
        // in steps of 1 degree
      {
      
  myservo.write(pos);  // tell servo to go to position in variable 'pos'
        delay(15);    // waits 15ms for the servo to reach the position
      }
     }
    else if (voice == "*door close")
    {
     
 for (pos = 180; pos >= 90; pos--) // goes from 90 degrees to 0 degrees
     
 {
    
    myservo.write(pos);   // tell servo to go to position in variable 'pos'
    
    delay(15);               // waits 15ms for the servo to reach the position
    
  }
    
}
    
else if (voice == "*light on")
    
{
    
  digitalWrite(RELAY, 1); // turn the LIGHT ON
    
}
    
else if (voice == "*light off")
    
{
    
  digitalWrite(RELAY, 0); // turn the LIGHT ON
    
}
    
else if (voice == "*fan on")
   
 {
    
  analogWrite(5, 0); //DC MOTOR rotates in anticlockwise
    
  analogWrite(6, 50);
    
}
    
else if (voice == "*fan of")
    
{
    
  analogWrite(5, 0); //DC motor  won't rotate
    
  analogWrite(6, 0);
    
}
    
else if (voice == "*low")
    
{
    
  analogWrite(5, 0);
    
  analogWrite(6, 50);
    
}
    
else if (voice == "*fast")
    
{
    
  analogWrite(5, 0);
    
  analogWrite(6,400);
    
}
    
else if (voice=="*medium")
    
{
    
    analogWrite(5,0);
    
    analogWrite(6,75);
    
}
    
    
voice = "";         //Reset the variable
  
}
}

Nice job posting the code within code tags.

Please so not use CAPITAL LETTERS for the body of your post. It is poor internet manners (considered to be shouting or yelling). If you can't find the caps lock key on your keyboard or phone, you probably won't be able to solve your Arduino problem.

I think you need to break your problem down into smaller pieces to isolate what is going on.

  1. If you ignore the bluetooth input for a second, and use the serial monitor to enter your commands, does the code perform as you wish? To test his, just substitute "Serial" for "BT" in your code and enter commands (e.g. *TV on#) in the monitor (set with no line ending).
 //while (BT.available())      //Check if there is an available byte to read
  while (Serial.available()) 
  {
    delay(10);              //Delay added to make thing stable
    //char c = BT.read();
    char c = Serial.read();
  1. If the code works with Serial input from the monitor, can you use a Bluetooth Serial Terminal app on the phone and software serial on the Arduino to directly send the text to the module and control the Arduino? The serial print on the monitor will show what was sent by the phone. The terminal app will also show the commands. I use Kai Morich's Serial Bluetooth Terminal https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal
    I have tested your code with my phone with pin 13 led substituted for pin 2, and can get the led to turn on and off with *TV on# and *TV off# sent from the phone.

  2. The last step will be to get the voice recognition working.

There are some other issues which can be dealt with when you know more about why your code is not working as you want.

The code you posted uses Software Serial and the Servo library. There may be a conflict with the two librarys SoftwareSerial and Servos - Motors, Mechanics, Power and CNC - Arduino Forum, but I don't believe that is your major issue at this time if none of the commands are working.

The code you posted uses the "String" object to read the input. On a microprocessor with limited memory that often leads to problems. This is probably not your immediate issue, but should be corrected. When you have worked out the other issues, it will be best to convert the input handling to null terminated character arrays (c strings). See this reference on how to receive serial data Serial Input Basics - updated - Introductory Tutorials - Arduino Forum

ok sorry for capital letters ..look..my project is car..

i make car and i want to talk my phone (switch on) and after it will get start with relay..i cant do this alone i dont know..can you write me you one code for this please..

my items is:
arduino uno
hc 05
breadboard
and my android phone with app (amr voice)

i cant do this alone i dont know..can you write me you one code for this please..

No. The forum doesn't work that way. It's place where people help others to write code and solve problems with the code they are writing.

There is a section of the forum called "Gigs and Collaborations" where people request for code to be written for them. Expect to pay someone to do this for you.

Good luck with your project.