How to make a DIY Bluetooth control boat using Arduino

How to make a DIY Bluetooth control boat using Arduino

Hello, welcome back. In this tutorial, we will learn how to make a DIY Bluetooth control boat using Arduino. It is mainly based on the Bluetooth module known as the HC-05. Also, this boat is powered by using two gear motors and all of these components are control using the Arduino UNO board and the L298N motor driver board. This Bluetooth control boat body is made of rigifoam. You can use any other material for that. This Bluetooth control boat is specially designed to travel on water as well as on land. You can try this Bluetooth control boat easily and cheaply at home. All the knowledge required for that is included in this tutorial. In a previous tutorial, we did a Bluetooth control car project using this HC-05 Bluetooth module. If you want to study that tutorial, use this link. Keep reading.

The process of this Bluetooth control boat

When power On this boat, the Bluetooth module starts the data communication process. That is, data is communicated between the Bluetooth control app and the Bluetooth module. After, this data is sent to the Arduino UNO board through the Serial communication method. Then, the motors rotate according to that data. All these are done through the Arduino program.

OK, let’s do this Bluetooth control boat project. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, create the boat using the following sizes. For that, I’m using the Rigifoam. You can use any other material.

Step 3

Thirdly, attach the motors and caster wheel to the boat. For that, use the pictures below.

Step 4

Next, cut the popsicle sticks using the following size. After, glue them to the wheels.

Step 5

Now, connect these wheels to the motors.

Step 6

Then, attach the motor driver board and Arduino board to the boat.

Step 7

After, connect the gear motors to the motor driver board. Then, connect the motor driver board to the Arduino UNO board. To do this, use the circuit diagram below.

How to make a DIY Bluetooth control boat using Arduino

Step 8

Now, attach the Bluetooth module to the boat. After, connect it to the Arduino UNO board. For that, use the circuit diagram above.

Step 9

Next, cover the backside of the boat and attach the battery holder to it.

Step 10

Afterward, connect the battery holder wires to the motor driver board. Then, glue the switch as you like.

Step 11

Now, remove the RX and TX jumper wires. After, connect this boat to the computer.

Step 12

Now, let’s create the program for this project. It is as follows.

  • The complete program of this project — Download
/*How to make a Bluetooth control boat using Arduino
   https://srituhobby.com
*/

#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5

void setup() {
  Serial.begin(9600);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char value = Serial.read();
    Serial.print(value);

    if (value == 'F') {
      forward();
    } else if (value == 'B') {
      backward();
    } else if (value == 'L') {
      left();
    } else if (value == 'R') {
      right();
    } else {
      Stop();
    }
  }
}

void forward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void backward() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void left() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void right() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void Stop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Code explanation

Firstly, motor pins are defined.

#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5

In the setup function, the motor pins are set as output pins.

void setup() {
  Serial.begin(9600);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

In the loop function,

void loop() {
//The serial communication is checked avialable or not.
  if (Serial.available() > 0) {
//Gets the values through the serial communication.
    char value = Serial.read();
    Serial.print(value);
//These values are checked using the IF condition. If the value is "F", the boat moves forward.
    if (value == 'F') {
      forward();
//If the value is "B", the boat moves backward.
    } else if (value == 'B') {
      backward();
//If the value is "L", the boat turns left.
    } else if (value == 'L') {
      left();
//If the value is "R", the boat turns right.
    } else if (value == 'R') {
      right();
//Otherwise, the robot stops.
    } else {
      Stop();
    }
  }
}

These are motor control functions.

void forward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void backward() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void left() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void right() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void Stop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Step 13

Then, select board and port. After, upload this code.

Step 14

Next, reconnect the RX and TX jumper wires. After, insert the batteries into the battery holder and power On this boat.

Step 15

Now, let’s set up the Bluetooth control app step by step. For that, use the steps below.

  • First, download and install the app below.
  • Then, go to the bluetooth settings and turns on. After, select the bluetooth module name and connect for it. For that use the “0000” or “1234” password.
  • Finally, open the Bluetooth control app and connect this app to the Bluetooth module.

Now you can control the boat using this app. OK, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.

How to make a DIY Bluetooth control boat using Arduino

Similar Posts

Leave a Reply

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