Bluetooth control car – Made with Arduino

jkjkjkj
This content provide you Experience

So, hey there, with this project, I tried to use an Arduino to create a Bluetooth-controlled car. To make it simple for you to grasp, I have given every detail. You may also view the more detailed video. You can learn to create it in 7-Simples steps .

To help you all understand, I have included every circuit diagram and explanation I could think of.

It is affordable and a smart choice for your project for school or college. There is no previous knowledge required!

Step 1: Materials Required

1. Any car chassis kit – Click here
2. Arduino UNO – https://www.amazon.in/dp/B07H1VZGBX?ref=myi_title_dp
3. L298 motor driver – https://robu.in/product/l293d-motor-driver-module/
4. Hc-05 Bluetooth module – https://www.amazon.in/dp/B019OR9YVU?ref=myi_title_dp
5. two batteries
6. Jumper Wires
7. mobile with Bluetooth

Better you get a kit online – click here

Step 2: Assemble a chassis with motor and wheels
You can check out through this link assembly of robotic car page >>> https://elconics.com/assembly-of-robotic-car-chassis/

Step 3 : Connection of motor driver and Arduino

Then join the four control pins of motor drive to the Arduino 2nd, 3rd, 4th and 5th pin socket.

Step 4: Connect Bluetooth Module to Arduino

Step 5: Upload Code

Download Arduino IDE to your computer and write a code on it.

Remove RX- TX pin >>>>Copy and paste code form here to Arduino IDE.

int MLF=8;  // MLF- Motor left forward
int MLB=9;  // MLB- Motor left Backward
int MRF=10; // MRB- Motor right Forward
int MRB=11; // MRF- Motor right backward
void setup() {
  Serial.begin(9600);
  pinMode(MLF,OUTPUT);
  pinMode(MLB,OUTPUT);
  pinMode(MRF,OUTPUT);
  pinMode(MRB,OUTPUT);
}

void loop() {
while(!Serial.available())
{
  //Stop();
  }
  int val = Serial.read();

 switch(val)
 {
  case 'F' : 
  Forward();
  break;

   case 'B' : 
  Backward();
  break;

  case 'R' : 
  Right();
  break;

  case 'L' : 
  Left();
  break;

   case 'S' : 
  Stop();
  break;
  
  
  
  }

}

void Forward()
{
  digitalWrite(MLF,HIGH);
  digitalWrite(MRF,HIGH);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,LOW);
  Serial.println("Moving Forward");
  delay(3000);
  
  
  }


void Backward()
{
  digitalWrite(MLF,LOW);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,HIGH);
  digitalWrite(MRB,HIGH);
  Serial.println("Moving BACKWARD");
  delay(3000);
  
  }

  void Right()
  {

    digitalWrite(MLF,HIGH);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,HIGH);
  Serial.println("Moving RIGHT");
  delay(2000);
    
    
    }


    void Left()
  {

    digitalWrite(MLF,LOW);
  digitalWrite(MRF,HIGH);
  digitalWrite(MLB,HIGH);
  digitalWrite(MRB,LOW);
  Serial.println("Moving LEFT");
  delay(2000);
    
    
    }

      void Stop()
  {

    digitalWrite(MLF,LOW);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,LOW);
  Serial.println("STOP");
  delay(2000);
    
    
    }

First upload this code
Then connect VCC – 5v and GND of Hc05-Gnd Rx to Tx and Tx to Rx make sure first you upload the code than connect Bluetooth Rx and Tx Because Rx and Tx works on Serial communication.
If you connect your Rx and Tx pin then you serial port will be engage with You HC-05 and You can’t upload the code through your Arduino cable

Detailed Code explanation

Initialization of variables

Initialization of motors for forward and backward movement.

int MLF=8;  // MLF- Motor left forward
int MLB=9;  // MLB- Motor left Backward
int MRF=10; // MRB- Motor right Forward
int MRB=11; // MRF- Motor right backward

Setting up Output for motors

void setup() {
  Serial.begin(9600);
  pinMode(MLF,OUTPUT);
  pinMode(MLB,OUTPUT);
  pinMode(MRF,OUTPUT);
  pinMode(MRB,OUTPUT);
}

Waiting for serial Communication

while(!Serial.available())
{
  
  }

If serial data is available

If Serial is available it will store data in Int datatype then we are checking the data with switch case method

int val = Serial.read();

if the Receiving is F then forward() function will call –>

void Forward()
{
  digitalWrite(MLF,HIGH);
  digitalWrite(MRF,HIGH);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,LOW);
  Serial.println("Moving Forward");
  delay(3000);
  
  
  }

if the Receiving is B then Backward() function will call –>

void Backward()
{
  digitalWrite(MLF,LOW);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,HIGH);
  digitalWrite(MRB,HIGH);
  Serial.println("Moving BACKWARD");
  delay(3000);
  
  }

if the Receiving is L then Left() function will call –>

 void Left()
  {

    digitalWrite(MLF,LOW);
  digitalWrite(MRF,HIGH);
  digitalWrite(MLB,HIGH);
  digitalWrite(MRB,LOW);
  Serial.println("Moving LEFT");
  delay(2000);
    
    
    }

if the Receiving is R then Right() function will call –>

void Right()
  {

    digitalWrite(MLF,HIGH);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,HIGH);
  Serial.println("Moving RIGHT");
  delay(2000);
    
    
    }

if the Receiving is S then Stop() function will call –>

void Stop()
  {

    digitalWrite(MLF,LOW);
  digitalWrite(MRF,LOW);
  digitalWrite(MLB,LOW);
  digitalWrite(MRB,LOW);
  Serial.println("STOP");
  delay(2000);
    
    
    }

Step 6: Download a mobile app

Download a app on your mobile phone named – Arduino Bluetooth control. And install it.

link to the application – https://play.google.com/store/apps/details?id=com.broxcode.arduinobluetoothfree

Take a look of mobile application

Step 7: Pair your Bluetooth module

  • Power up your Arduino with 9v- 12v  battery or cell.
  • Open Arduino Bluetooth control App make Sure there is red led turned on of Bluetooth module.
  • Now pair your Bluetooth module named as HC-05
  • Enter pin number 1234 or 0000
  • After pairing open the app and choose HC-05 to pair with. Check the LED of Bluetooth module, its blinking rate would have been very slow now.

Now follow these Steps to control from Button arrow key

Boom you are done now you can control it from arrow keys

Leave a Comment

Your email address will not be published. Required fields are marked *

Related post