Menu
Close
SIGN IN REGISTER
Forgot password?
Close
Cart
21.07.2023

Making a Bluetooth Controlled Vehicle with Arduino

Building a Bluetooth Controlled Vehicle with Arduino

Hello friends, in this blog post, we will talk about building a bluetooth controlled vehicle with Arduino.

Materials List

·Arduino Uno

·Hc-06 Bluetooth

·L298N Motor Driver

·Power Source (9v Battery, Lipo Battery, etc.)
 
 

Arduino Code

String readString;
const int in1 = 7;
const int in2 = 6;
const int in3 = 5;
const int in4 = 4;

void setup(){

pinMode(in1, OUTPUT); //Set all pins as OUTPUT for motor control.
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);

Serial.begin(9600); /* Start serial communication */
}
void loop()
{
while(Serial.available()){

delay(3);
char c= Serial.read();
readString+=c;
}
if(readString.length()>0){
Serial.println(readString);
if(readString=="a"){


digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);


}
if(readString=="b"){

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
if(readString=="c"){

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

}

if(readString=="d"){


digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);

}
if(readString=="e"){

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

}
readString="";
}
}