Arduino Projects

Arduino Bluetooth controlled Robot using L298n Motor Driver Android App

Bluetooth controlled Robot Project Description:

 

Bluetooth Controlled Robot- In this Tutorial, you will learn how to make an Arduino Bluetooth controlled Robot Car using L298N Motor Driver and An Android Cell Phone Application. You can also read my article on how to design your own Android cell phone application in Android Studio.

The application is designed in Android studio, with the help of this application the Robot car can be wirelessly controlled using your Android Cell Phone. The Application download link is given below. This project is based on my previous two tutorials.


Bluetooth Arduino: Pin Code and Name changing using AT commands

Bluetooth controlled Robot

In this tutorial, I explained how to change the name of the Bluetooth module and how to change the Pin code or password using the AT commands. This Tutorial covers everything you want to learn about the HC-05 Bluetooth Module. If you are using a Bluetooth module for the first time then I highly recommend you should watch this Tutorial.

Arduino L298N Motor Driver Interfacing and Programming:

While in this project I explained, how to assemble the robot parts and how to use the L298N motor driver to control the forward, Left, Right, and Reverse movement. In this tutorial, I also explained how to control the speed of a dc motor using the pulse width modulation. If you are a beginner and you have never used the Bluetooth module and L298N motor driver then I recommend you should first watch these tutorials and then you can resume from here.


In this Tutorial based on the Bluetooth Controlled Robot, I will only talk about the modifications which are

  1. Bluetooth module (HC-05) interfacing with Arduino
  2. Arduino Programming and finally number
  3. Testing

Let’s get started!!!!

Amazon Links:

Arduino Uno

Arduino Nano

Mega 2560:

Robot Car chassis kit:

L298N motor driver:

Bluetooth Module: Hc-05:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

DISCLAIMER:

Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Bluetooth Controlled Robot Interfacing:

Bluetooth controlled Robot

All the connections are exactly the same as explained in my previous tutorials the links are given above. The only modification that I did is the addition of the HC-05 Bluetooth module.

The connections are explained in the Video, which is given at the end.

The VCC wire of the Bluetooth module is connected with the 5 volts.

The green wire is the ground wire and is connected with the Arduino’s ground.

The white wire is the TX wire and is connected with pin number 2 of the Arduino.

The yellow wire is the Rx wire and is connected with the Arduino’s pin number 3.


Bluetooth controlled Robot

During the testing, I used a 12v adaptor over here. This is the DC female Power Jack. after I am satisfied with the testing then I will simply disconnect the 12v adaptor and turn on this button



Bluetooth controlled Robot

And will use batteries to power up the robot car. For the complete explanation, you can watch a video tutorial given at the end of this Article. Now let’s have a look at the programming.

Download Application: robot


Bluetooth Controlled Robot Arduino Programming:

This is the modified version of the code which I used in my previous tutorial “Arduino L298N dc motor control code” Link to the video Tutorial is given Above.  In this project, I added the softwareserial.h which is a header file specially created for making multiple serial ports. As you know in Arduino we have only one serial port which is on pin number 0 and pin number 1, which are the RX and TX pins, as I always say never use the Arduino’s default serial port for the communication with other modules, use the Arduino’s default serial port only for the debugging purposes. We can use the SoftwareSerial library to create another Serial port.

#include <SoftwareSerial.h>
SoftwareSerial Blue(2, 3);

int ena = 5; 
int enb = 6; 

int in1 = 8; 
int in2 = 9; 
int in3 = 10; 
int in4 = 11; 

I defined some commands, 92 means forward, 79 means left, 71 means right, 91 means reverse and 10 means stop. These are the commands which the android application will send to the Arduino.


long int data;
long int command1 = 92;// forward
long int command2 = 79; // left
long int command3 = 71; //  right
long int command4 = 91; //  Reverse
long int command5 = 10; // stop



char state = 0;


void setup()
{
Serial.begin(9600);
Blue.begin(9600);

  pinMode(ena, OUTPUT); 
  pinMode(enb, OUTPUT); 

  pinMode(in1, OUTPUT); 
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  
 analogWrite(ena, 255); 
 analogWrite(enb, 255);
 delay(1000);
}

void loop()
{

  while(Blue.available()==0) ;

if the Bluetooth module hasn’t received any data/command from the android cell phone application then simply stay here and wait for the command.

if the Bluetooth module has received data from the android cell phone application, then simple store that data in variable data. Then the received command is compared with all the predefined commands and turn on and turn off the motors accordingly



 if(Blue.available()>0) 
{
data = Blue.parseInt();
} 
delay(100);
//Serial.print(data);

if (data == command1) // Forward
{
  
  digitalWrite(in1, HIGH); 
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  //delay(100);
}
   
   if( data == command2) // left
   {
 digitalWrite(in1, LOW); 
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(100); 
   }

   if( data == command3) // Right
   {
  digitalWrite(in1, HIGH); 
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(100); 

   }
   
   if( data == command4) // Reverse
   {
  digitalWrite(in1, LOW); 
  digitalWrite(in2, HIGH);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  delay(100); 
   }

   
      if( data == command5) // Stop
   {
   digitalWrite(in1, LOW); 
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
 // delay(100); 
 
   }

 }

Other Related Projects:

Wireless Joystick controlled Robot Car using Arduino, 433Mhz RF, and L298N Motor Driver

Arduino IOT Project: Nodemcu ESP8266 wifi Robot Car “L298N motor driver + Blynk + Joystick”

Safe distance maintaining Car to Avoid accident using Ultrasonic Sensor

Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

2 Comments

Leave a Reply

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

Back to top button