Configure Bluetooth HC - 05 with Arduino Mega 2560

i cannot understand, when i trying to configure and connect bluetooth with my android device. (i used bluetooth HC-05 from lc-technology and Arduino Mega 2560) I’m trying to connect the arduino and android with bluetooth but it failed. This is a code for arduino

char incomingByte;  
int LED = 12;

void setup (){
    pinMode(LED, OUTPUT);
    Serial.begin(9600);
}
void loop(){
    if (Serial.available()){
        incomingByte = Serial.read();
        if(incomingByte == '1'){
            digitalWrite(LED, LOW);
        }
        if(incomingByte == '0'){
            digitalWrite(LED, HIGH);
        }
    }
}

I try to send data from bluetooth device (i use Bluetooth Terminal and BlueTerm) to Bluetooth Arduino and never give a response i've been trying to uses another pin for tx & rx on Arduino Mega 2560, but it never give a response.

Does someone have a solution on that problem ? Thanks before for your help. I'll apreciate you for your help.

You will be better off forgetting about the LED, and addressing the real problem.

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

I had the same your problem when I connect the HC-05 from lc-technology to the pin 0 and 1 of Arduino UNO (UART TTL (5V) serial communication): the HC-05 was able to receive data from Arduino, but not possible for Arduino to receive data from HC_05. If I use other Arduino pins with SoftwareSerial then both ways are ok.

I tried an HC-05 from a different maker (http://hobbycomponents.com/index.php/hc-05-master-slave-bluetooth-module.html) and everything works well using Arduino pins 0 and 1.

Waiting for an oscilloscope for more in-depth tests.

lelino:
I tried an HC-05 from a different maker and everything works well using Arduino pins 0 and 1.

This suggests a mechanical fault with the original. Some people have had a solder bridge on the backboard.

Nick_Pyner:

lelino:
I tried an HC-05 from a different maker and everything works well using Arduino pins 0 and 1.

This suggests a mechanical fault with the original. Some people have had a solder bridge on the backboard.

I don't think so cause it works properly with SoftwareSerial using other pins. Should it be a mechanical fault, it would not have had to work even with SoftwareSerial !!!
Still waiting for the oscilloscope :frowning:

OK, that proves the BT module is kosher - which tends to point to the code or procedure being suss, neither of which require an oscilloscope to fix. Reading reply #1 again might be more constructive than waiting for one.

I finally got the oscilloscope and made my tests.

This is the tension levels of the LC Technology module (3.3V down to 1.7V):

This is the tension levels of the other module (3.1V down to 0V):

The two modules I tested:

An additonal picture taken during the tests:

After these tests I PERSONALLY got to the conclusion that, as it happend to me, the problem of bayudwirp is in the LC Technology module itself cause it doesn't properly manage the tension levels of the TX pin: it never gives a response cause Arduino couldn't handle the tension levels from the bluetooth module.

Nick_Pyner:
You will be better off forgetting about the LED, and addressing the real problem.

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

Your guide is a masterpiece!!!

I love this: "The big secret about Arduino to Android communication via Bluetooth is:

...

there is no big secret"

Thanks a lot!

Glad to be of help!