Connection between phone and arduino via bluetooth

I’ve succeeded connecting my phone to the arduino via bluetooth and even send a messege from the phone to the arduino but I couldn’t send a messege from the arduino to the phone.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
char c = ’ ';
int buf[64];
int len = 0;

void setup (){
Serial.begin (9600);
Serial.println(“Arduino is ready”);
delay(500);
mySerial.begin(9600);
Serial.println(“Bluetooth is ready”);
}

void loop (){
if(Serial.available()){
len=Serial.available();
for(int i = 0; i<len;i++){
buf = Serial.read();
_ mySerial.write(buf*);_
_ Serial.write(buf);
}
}
if(mySerial.available()){
len=mySerial.available();
for(int i=0; i<len; i++){
buf = mySerial.read();
Serial.write(buf);
}
}
// for(int i=0;i<buf.length;i++)
// Serial.println(buf);
}*

this was my program._

omridoren:
I couldn't send a messege from the arduino to the phone.

This should need no more than

Serial.println("hello");

and the hard stuff is in the opposite direction. I suspect your code is irrelevant, and it is more likely to be simply a matter of sloppy wiring. If you think the wiring is kosher, you might still test it by sending an AT command and wait for a non-response. If you actually get a response, it rather suggests that all your problems are at the Android end but, since you are actually able to send therefrom, I don't dare guess what it could be.

This is my wiring. Did I do something wrong there?

No, it's not your wiring, it is a picture of your intended wiring, drawn by Martyn Currey. Good guidance is no proof of proper execution.

omridoren:
I've succeeded connecting my phone to the arduino via bluetooth and even send a messege from the phone to the arduino but I couldn't send a messege from the arduino to the phone.

As you can receive a message it seems the communication between Arduino and HC05 is fine. Are you sure your phone is actually receiving the response, and processing it as you intend?

this was my program.

Not really - you failed to add code tags (as described in the sticky) so it got treated as text and bbcode and mangled.

wvmarle:
Are you sure your phone is actually receiving the response, and processing it as you intend?

Not really - you failed to add code tags (as described in the sticky) so it got treated as text and bbcode and mangled.

How do I check it?

That's a very good question, and with you knowing exactly what you have installed on your phone you are the only one that can possibly answer that.

wvmarle:
That’s a very good question, and with you knowing exactly what you have installed on your phone you are the only one that can possibly answer that.

I’ve downloaded the app called “Bluetooth Terminal HC-05”

You should not need an app that purports to be HC-05 specific, and I wouldn't trust it. Plain ordinary Bluetooth terminal should do.

I don't think I can build the code right. May anyone help me build a new one?

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