Problem communicating with HC-05 Bluetooth module

This post is edited after Robin2's comment

I wrote a code for simple data transmission between an android smart phone and arduino UNO. it was working fine just last week.but now it isn't!.

I transmitted data between PC and android phone and printed them on Serial monitor and android device.i took off wires and made a small robot working with IR remote control.then I wanted to control robot by bluetooth but now just i could send data from arduino to android device and Serial monitor doesn't print anything.

actually if (BTSerial.available()) doesn't work, but if (Serial.available()) works correctly.

I completely disconnected every thing from Arduino and just bluetooth module is connected to it as show below, but still not working.:frowning:


it's code:

#include <SoftwareSerial.h>

SoftwareSerial BT(2,3);

void setup() {
  Serial.begin(9600);
  BT.begin(9600); 
}

void loop() {
  if(Serial.available())
    BT.write(Serial.read());

  if(BT.available())
    Serial.write(BT.read());

}

when i take off wire from pin 2 Serial monitor prints some odd characters. it shows Serial is working and problem is from module probably.by adding a " Serial.print("hello"); " to first if, I realized " if(BTSerial.available()) " is not running at all when i send information by phone:

#include <SoftwareSerial.h>

SoftwareSerial BT(2,3);

void setup() {
  Serial.begin(9600);
  BT.begin(9600); 
}

void loop() {
  if(Serial.available())
    BT.write(Serial.read());

  if(BT.available()){
    Serial.write(BT.read());
    Serial.println("HELLO");
  }
}

i used several bluetooth terminals but couldn't solve it.
can it be a hardware problem or there is a problem in configuration?
Thanks.

If it was working and you "took off wires" and "completely disconnected every thing" those are almost certainly the cause of the problem.

Make a simple pencil drawing showing how you have everything connected now and post a photo of the drawing.

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

...R
Serial Input Basics

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

It is good practice to use a 1k/2k voltage divider on the Arduino Tx.

Please restore your Original Post to what it was when I commented on it. Now my comments just look stupid.

Post new information in the proper chronological order so people can follow the discussion.

Did you study the link I gave you?

...R