Im trying too simply communicate between my android phone and my arduino using the HC-05 bluetooth module.
While my module works and i am able too send and receive data on my phone, the data of my btData variable seems too instantly get lost after being received. On my android app i get the input data output like written in my code and then instantly an empty output/line.
Writing "1"/"off" into my console does not trigger my if(btData == "1")... part of the code.
I have attached my code, aswell as the android terminal and my arduino HC-05 connection.
Hopefully someone is able too help since i cant find any error.
#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11
SoftwareSerial btSerial(rxPin, txPin);
String btData;
void setup() {
btSerial.begin(9600);
btSerial.println("bluetooth available");
}
void loop() {
if (btSerial.available()) {
btData = btSerial.readString();
btSerial.println(btData);
if (btData == "1") {
btSerial.println("LED on Pin 13 is on");
}
if (btData == "off") {
btSerial.println("LED on Pin 13 is off");
}
}
delay(100);
}