Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
So BT.begin(9600); is a sort of function statement and works using software serial lines mentioned above in the code
I want to move forward for 4 seconds then move right for 2 seconds then wheels should stop
if (readvoice.length() > 0) {
Serial.println(readvoice);
delay(100);
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);
}
else if (readvoice == "move1")
{
// first stop in case you are still moving from another command
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
// move forward
digitalWrite(3, HIGH);
digitalWrite (4, HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(4000); // for 4 seconds
// stop
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
// turn right
digitalWrite (3,HIGH);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
delay (100);
// move forward
digitalWrite(3, HIGH);
digitalWrite (4, HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(2000); // for 2 seconds
// stop
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
// done with move1
}
readvoice="";}} //Reset the variable