Arduino send string to App inventor

HI! Im using app inventor to receive data from arduino. In our project, we send a certain text to the arduino (i.e “305”)
then the arduino will reply with a text (i.e “10 steps left”). The android app can send data to the Arduino, but receiving side is a bit of a problem. How can the Arduino send string to the android app.

#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11);// RX | TX

String readString;
String 305string = "10 steps left";
String 302string = "5 steps right";

void setup() {
  BT.begin(9600);
  pinMode(ledpin, OUTPUT);
}
void loop () {
  while (BT.available()) {
    delay(3);
    char c = BT.read();
    readString += c;
  }
  if (readString.length() > 0) {
    BT.println(readString);
    if (readString == "305") {
      digitalWrite(ledpin, HIGH);
      BT.println(305string);
    }
    if (readString == "302") {
      digitalWrite(ledpin, LOW);
      BT.println(302string);
    }
    readString="";
  }
}

Do you have a problem sending the String from the Arduino or dealing with it when it is received by Android ?

Sending it should be easy. In fact you seem to be doing it already in your program

 BT.println(readString);

seems to me to be sending what you have received back via Bluetooth.

If you have a problem dealing with it on teh Android device then you are asking in the wrong forum.

The code

BT.println(readString);

is use to read incoming data from the android phone.

The code I used for sending data to the android phone is this:

BT.println(305string);

is it correct?

michael004: The code

BT.println(readString);

is use to read incoming data from the android phone.

No it is not. This is sending a string to the BT

The code I used for sending data to the android phone is this:

BT.println(305string);

is it correct?

No, and the compiler told you it wasn't.

Variable names can not start with numbers.