Bluetooth Controlled Robot
Tags: beginners, arduino, programming, tutorial
Published: 2023-03-02 13:36:59

In this blog post, I will provide you a tutorial on constructing a robot car controlled by Bluetooth technology using an HC-05 Bluetooth module and an Arduino microcontroller. To establish a connection between your mobile device and the Bluetooth module, any Bluetooth mobile application that is accessible through the Playstore can be utilized.


![A Picture of a Robot Car](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9oa7tgq0xwfy3gx1ve7b.png)

<u>**Components Required:**</u>

1. Arduino UNO
2. HC-05 Bluetooth Module  
3. L298N Motor Driver Module
4. Robot Chassis  
5. 4 x 5V Geared Motors  
6. Connecting Wires  
7. Battery Holder
8. Power Supply 
9. Android Phone 
10. Bluetooth Controller App

<u>**Arduino UNO**</u>
Arduino is a user-friendly open-source electronics platform that utilizes both software and hardware components. These boards can interpret various inputs such as light sensors, button presses, or social media messages and translate them into outputs like motor activation, LED illumination, or online publishing. The programming language for Arduino is based on wiring, and the software development environment is known as the Arduino Software (IDE), which is based on processing.

![A Picture of an Adruino](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdni0w5fyzskp092nvxw.png)

<u>**HC-05 Bluetooth module**</u>
The HC-05 module is a well-known wireless component that can offer two-way (full-duplex) features to your projects. You can use this module to create communication between two microcontrollers, like Arduino, or to interact with any device that has Bluetooth capabilities, such as a laptop or phone. This process can be simplified by utilizing various readily available Android applications.

![A Picture of Hc-05 Bluetooth Module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcz6gcq37ecmlavd1v4j.jpg)

<u>**L298N Motor Driver Module**</u>
The L298N motor driver module is an electronic component used to control the speed and direction of DC and stepper motors in various applications, including robotics and automation. It consists of two H-bridges, each capable of controlling the direction of a motor, and can handle a wide range of input voltages and output a maximum current of 2A per channel. The module is typically controlled using a microcontroller, such as an Arduino or Raspberry Pi, making it a versatile and reliable tool for motor control.

![A Picture of a L298N Motor Driver Module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrpzr5tqfl5uwpurgypp.jpg)

<u>**Gear Motors**</u>
Gear motors are a type of electric motor that integrates a gearbox into the design. The gearbox consists of a series of gears that reduce the output speed of the motor while increasing the torque output. Gear motors are widely used in a variety of industrial and consumer applications, including robotics, automotive, and home appliances.

![A Picture of Gear Motors](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wn0fbf0fv7qfepxhfng8.jpg)

In that Bluetooth app, clicking 'f' moves the motors forward, while pressing 'b' causes the motor to spin back. Similar to this, when tapping 'r' , 'l' and 'p', the motors 'r' turns right , the motor 'l' turn left and the motor 'p' causes motor to pause/stop, respectively.

<u>**Code:**</u>
```python
void loop()
{
  if (Serial.available())
  {
    value = Serial.read();

    if (value == 'f')
    {
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      digitalWrite(7, LOW);
      Serial.print("FORWARD");
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
    }
    else if (value == 'b')
    {
      digitalWrite(4, LOW);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      digitalWrite(7, HIGH);
      Serial.print("BACKWARD");
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
    }
    else if (value == 'r')
    {
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      digitalWrite(7, LOW);
      Serial.print("RIGHT");
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
    }
    else if (value == 'l')
    {
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      digitalWrite(7, LOW);
      Serial.print("LEFT");
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
    }
    else if (value == 'p')

    {
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      digitalWrite(7, LOW);
      Serial.print("PAUSE");
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
    }
    Serial.println();
  }
}
```

_I hope you enjoyed reading this blog and got some brief info about Bluetooth Controlled Robot._

THANK YOU ❤️