HELP program code to control rc car via TILT/ACCELEROMETER via bluetooth

i already made this ‘control rc car via voice control via bluetooth’

l293d ic
gizduino
hc-05 module
the circuit diagram for voice control is attached.
the program i use is this

#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11); //TX, RX respetively
String readvoice;

void setup() {
BT.begin(9600);
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);

}
//-----------------------------------------------------------------------//
void loop() {
while (BT.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = BT.read(); //Conduct a serial read
readvoice += c; //build the string- “forward”, “reverse”, “left” and “right”
}
if (readvoice.length() > 0) {
Serial.println(readvoice);

if(readvoice == “forward”)
{
digitalWrite(3, HIGH);
digitalWrite (4, HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(100);
}

else if(readvoice == “reverse”)
{
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6,HIGH);
delay(100);
}

else if (readvoice == “right”)
{
digitalWrite (3,HIGH);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
delay (100);

}

else if ( readvoice == “left”)
{
digitalWrite (3, LOW);
digitalWrite (4, HIGH);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
}

else if (readvoice == “stop”)
{
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
}

readvoice="";}} //Reset the variable

its working perfectly…

**now i need to control my rc car using android phone’s tilt/accelerometer via bluetooth
anyone can help me how to modify this voice control program code to tilt/accelerometer :confused: :confused: also the app that i will use on it please i really need this guys :frowning: :frowning:

I guess you need a program running on your Android device that reads the tilt sensor and sends a suitable message to the Arduino. If you can get it to send "forward" etc. you would not need to change the Arduino code.

Writing Android programs is beyond the scope of this Forum.

...R

its working perfectly..

You got lucky. That way of reading serial data is crap.

Do NOT use delay() while reading serial data. Do not assume that a complete packet has arrived when the while loop ends.

Do not clear the String unless the command in the String was recognized.

Do not do this crap:

readvoice="";}} //Reset the variable

Every statement and every } goes on its own line.

Do not cross-post. Other thread removed.