DEV Community

Cover image for Bluetooth Controlled Robot
Aman Chhetri
Aman Chhetri

Posted on

Bluetooth Controlled Robot

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

Components Required:

  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

Arduino UNO
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

HC-05 Bluetooth module
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

L298N Motor Driver Module
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

Gear Motors
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

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.

Code:

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();
  }
}
Enter fullscreen mode Exit fullscreen mode

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

THANK YOU ❤️

Top comments (0)