Bluetooth communication using arduino yun

Hi

I have an arduino code for communicating with bluetooth module HC-05

the arduino code is

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
 
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  Serial.println("Ready!");
 
  // set the data rate for the SoftwareSerial port
 
  // for HC-05 use 38400 when poerwing with KEY/STATE set to HIGH on power on
  mySerial.begin(9600);
}
 
void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

hardware connection of bluetooth module

vcc => 5v

TXD => 10

RXD => 11

GND

Arduino code is not shown error it will uploaded to arduino yun successfully but in serial monitor i send "AT" command means it doesn't replay "OK"

That is because you are not following instructions. If you want to configure theHC-05, yoiu need to put it into AT mode. As the code says

// for HC-05 use 38400 when poerwing with KEY/STATE set to HIGH on power on

but you have written

mySerial.begin(9600);

and I bet you have not set the KEY pin high either.

I suspect you have gotten this from a bad source. You might get more joy from

http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/

Thanks Nick_Pyner for the link its working fine