Voice Controlled car

will this coding work for a voice controlled car

#include <SoftwareSerial.h>

SoftwareSerial BT(0, 1);
String readvoice;

void setup() {
BT.begin(9600);
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(3, 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 == "*back#")
{
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6,HIGH);
delay(100);
}

else if (readvoice == "*left#")
{
digitalWrite (3,HIGH);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
delay (800);
digitalWrite(3, HIGH);
digitalWrite (4, HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(100);

}

else if ( readvoice == "*right#")
{
digitalWrite (3, LOW);
digitalWrite (4, HIGH);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (800);
digitalWrite(3, HIGH);
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

The beauty of Arduino is that you can try it and see! Let us know if it works.

Be warned that use of Strings is not advised. They may cause your Arduino to crash.

Please use code tags when posting code.

will this coding work for a voice controlled car

No. You can NOT do software serial and hardware serial on the same pins at the same time.

But assuming you get the pins sorted out, and String vs string issues aside, what mechanism in there takes voice in and converts the voice into a String?

arduin_ologist:
But assuming you get the pins sorted out, and String vs string issues aside, what mechanism in there takes voice in and converts the voice into a String?

secretary.jpg