I am connecting my Arduino Uno to HC-06 bluetooth module (FC-114), I had a strange problem that I had not figured out its solution yet...
I cannot transmit and receive data at the same time from the Bluetooth terminal at my Android phone.
However, when I disconnect the Arduino Rx, I can transmit from the Arduino and I receive it successfully at my Android phone terminal.
And, when I disconnect the Arduino Tx, I can receive at the Arduino what ever I send from my Android phone terminal.
I use this test code,
int incomingByte = 0; // for incoming serial data
int ledpin=13; // led on D13 will show blink on / off
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(ledpin,OUTPUT);
digitalWrite(ledpin,0);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
if (incomingByte == '1'){
digitalWrite(ledpin,1);
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
if (incomingByte == '0'){
digitalWrite(ledpin,0);
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
}