Hi,
I'm trying to use HC-05 BT module as "Serial" input/putput mode.
With this simple code I'm trying to send 'H' or 'L' via Bluetooth Terminal on Android phone to LED blick or not.
char val; // variable to receive data from the serial port
int ledpin = 13; // LED
void setup() {
pinMode(ledpin, OUTPUT);
Serial.begin(57600);
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
}
if( val == 'H' ) // if 'H' was received
{
digitalWrite(ledpin, HIGH); // turn ON the LED
} else {
digitalWrite(ledpin, LOW); // otherwise turn it OFF
}
delay(100); // wait 100ms for next reading
}
The wiring schema is:
BT RX -> Arduino RX
BT TX -> Arduino TX
The behaviour is that when I start the Serial monitor on PC and I type 'H' or 'L', works, and I receive in BT Terminal of Phone the command ('H', 'L')
But when I type 'H' or 'L' in BT Terminal of Phone the LED soesnt blink and didnt receive in Serial of PC.
I've tried to change pin order (RX to TX, TX to RX) and nothing, it doesnt work.
I've' enssured that the BT Terminal of phone doesnt send end flag like '\r', '\n' or both.
I'be ensured that te baudrate, and mode of HC-05 is correct.
The question is why I receive in BT Term of phone the commands but in the other way does not?
Thank you.