Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Components and supplies

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Arduino Nano R3
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
SparkFun Dual H-Bridge motor drivers L298
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
HC-05 Bluetooth Module
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
RGB Diffused Common Anode
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
SparkFun Logic Level Converter - Bi-Directional
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Resistor 330 ohm
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Breadboard (generic)
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
SparkFun Breadboard Power Supply Stick 5V/3.3V
×1
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
DC Motor, 12 V
×2
Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Male/Female Jumper Wires
×1

Apps and online services

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle
Arduino IDE
Arduino BlueControl
Available in Playstore.

About this project

The project uses a mobile phone to communicate with a robot via bluetooth. I always wanted to build a robot and control it via mobile phone. After a long gap of more than 12 years, I took up the task of building a robot and operate it. This is also my first project in the Arduino Project Hub. Electronics and robotics is one of my favourite hobbies and therefore I took the task of building the robot in this time of lockdown due to Covid19.

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

The robot senses bluetooth signals transmitted from the mobile phone. It uses the HC-05 bluetooth module to sense the command signals from the mobile phone and controls the robot. I used the ArduinoBlueControl app to control the robot.

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

The heart of the robot is the Arduino Nano. It receives the signals from the HC-05 module via serial communication and controls the motors via L298N motor driver module for motion in forward, reverse, left and right directions.

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Care should be taken to connect the TX and RX pins of the HC-05 module with the Arduino Nano. A logic level converter is used for the same.

The robot uses HC SR-04 ultrasonic sensor module to detect obstacles in its path. On sensing any obstacle during its forward motion, the robot stops.An RGB LED is used to show the status of the robot.

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

The robot is assembled in a 2-wheel base consisting of two geared drive motors. The circuitry is assembled over a breadboard with power supply (3.3v and 5v). The Arduino Nano cannot drive the motors directly due to much higher current requirement for the motors. Therefore the L298N motor driver module is used to drive the motors. The PWM signals from the Arduino Nano is used to control the speed of the motors via the ENA and ENB pins of the L298N motor driver module.

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Here is a short video of the robot in operation:

Hope you liked my bluetooth controlled obstacle avoidance robot. This robot can be modified and extended for uses in home automation, obstacle avoidance vehicles for the shop floor etc. and many more uses.

Code

  • Bluetooth Controlled Robot_Arduino Code.
Bluetooth Controlled Robot_Arduino Code.C/C++
/* Bluetooth Controlled Obstacle Avoidance Robot
   Prepared by : Alok Talukdar
   Date        : 09.05.2020
*/

#include<SoftwareSerial.h> // To use any pin on Arduino for Serial communication.

// Define the digital pins for L298 motor control module.

#define IN1 5    // for right motor
#define IN2 4    // for right motor
#define IN3 3    // for left motor
#define IN4 2    // for left motor
#define ENA 9    // Enable A for PWM control of right motor
#define ENB 10    // Enable B for PWM control of left motor

// Define the digital pins for RGB LED control

#define redLED   8
#define greenLED  A0
#define blueLED 11

// Set up the HC-SR04 Ultrasonic sensor module

const int trigPin = 6;      // TRIG pin connected to pin D6 of Arduino Nano
const int echoPin = 7;      // ECHO pin connected to pin D7 of Arduino Nano

int i,j,k = 0;

float duration,distance;  // variables for distance measurement

// Set up the HC05 Bluetooth module

SoftwareSerial mySerial(12,13); // (12 --> RX , 13 --> TX)

String data;                    // variables for Bluetooth control
int btVal;

void setup() {
  // put your setup code here, to run once:

  pinMode(trigPin,OUTPUT);       // Configure pin D6 to transmit ultrasonic pulses
  pinMode(echoPin,INPUT);        // Configure pin D7 to receive ultrasonic pulses

  mySerial.begin(9600);          // Configure the Software serial at Baud rate 9600

  pinMode(IN1,OUTPUT);           // Configure IN1 - IN4 as OUTPUT to control motors
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);
  pinMode(ENA,OUTPUT);
  pinMode(ENB,OUTPUT);

  pinMode(redLED,OUTPUT);
  pinMode(blueLED,OUTPUT);
  pinMode(greenLED,OUTPUT);

  digitalWrite(IN1,LOW);         // Configure the status of the IN1 - IN4 as LOW
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,LOW);
  digitalWrite(IN4,LOW);


  analogWrite(redLED,255);    // Switch OFF LED's. RGB LED is common anode type.
  digitalWrite(blueLED,HIGH);
  digitalWrite(greenLED,HIGH);
}

void loop()
{
  // put your main code here, to run repeatedly:

  while (mySerial.available())
  {
     data = mySerial.readStringUntil('\n');
  }

     btVal = (data.toInt());

     switch (btVal) 
   {
      case 1:                                
        
        forward();
        digitalWrite(greenLED,LOW);
        analogWrite(redLED,255);
        digitalWrite(blueLED,HIGH);
        dist();
        break;

      case 2:                 
       
        reverse();
        digitalWrite(greenLED,HIGH);
        analogWrite(redLED,255);
        digitalWrite(blueLED,LOW);
        break;

      case 3:         
       
        left();
        break;
        
      case 4:                     
        
        right();
        break;
        
      case 5:                                            
        
        stoprobot();
        digitalWrite(greenLED,HIGH);
        analogWrite(redLED,0);
        digitalWrite(blueLED,HIGH);
        break;

      default:
        digitalWrite(greenLED,HIGH);
        analogWrite(redLED,255);
        digitalWrite(blueLED,HIGH);
        break;

             
    }

        if (mySerial.available() < 0)                              
    {
     //Serial.println("No Bluetooth Data ");          
    }
}
     // motor control function declarations

     

     void forward()
     {
       for(i=0;i<=100;i++)
       {
       analogWrite(ENA,i);
       analogWrite(ENB,i);
       digitalWrite(IN1,HIGH);
       digitalWrite(IN2,LOW);
       digitalWrite(IN3,LOW);
       digitalWrite(IN4,HIGH);
       }
     }

     void reverse()
     {
       for(j=0;j<=100;j++)
       {
       analogWrite(ENA,j);
       analogWrite(ENB,j);
       digitalWrite(IN1,LOW);
       digitalWrite(IN2,HIGH);
       digitalWrite(IN3,HIGH);
       digitalWrite(IN4,LOW);
       }
     }

     void left()
     {
       analogWrite(ENA,127);
       analogWrite(ENB,0);
       digitalWrite(IN1,HIGH);
       digitalWrite(IN2,LOW);
       digitalWrite(IN3,HIGH);
       digitalWrite(IN4,HIGH);
     }

     void right()
     {
       analogWrite(ENA,0);
       analogWrite(ENB,127);
       digitalWrite(IN1,HIGH);
       digitalWrite(IN2,HIGH);
       digitalWrite(IN3,LOW);
       digitalWrite(IN4,HIGH);
     }

     void stoprobot()
     {
       analogWrite(ENA,0);
       analogWrite(ENB,0);
       digitalWrite(IN1,LOW);
       digitalWrite(IN2,LOW);
       digitalWrite(IN3,LOW);
       digitalWrite(IN4,LOW);
     }
      void dist()
     {
       digitalWrite(trigPin,LOW);          // to send a pulse via the TRIG pin of HC-SR04
       delayMicroseconds(2);
       digitalWrite(trigPin,HIGH);
       delayMicroseconds(10);
       digitalWrite(trigPin,LOW);

       duration = pulseIn(echoPin,HIGH);   // read the duration of the pulse

       distance = (duration*0.0343)/2;     // measure the distance in cms. Speed of sound is 340 m/s or 0.0343 cm/us
       if(distance<20)                     // if distance is < 20 cms , STOP robot 
       {
        stoprobot();
        digitalWrite(greenLED,HIGH);
        analogWrite(redLED,0);
        digitalWrite(blueLED,HIGH);
       }
        delay(1000);

     }
    
    

Schematics

Circuit diagram of the robot.Bluetooth‑Controlled Obstacle‑Avoidance Robot: Build a Smart, Remote‑Operated Vehicle

Manufacturing process

  1. Vision‑Based Obstacle‑Avoiding Mobile Robot on Raspberry Pi
  2. Build a Bluetooth‑Controlled Raspberry Pi Robot with Audio Feedback
  3. Build a Wi‑Fi‑Controlled Raspberry Pi Robot with Python – Step‑by‑Step Guide
  4. AI-Powered Obstacle Avoidance System with Arduino and Ultrasonic Sensors
  5. Build a Voice‑Controlled Robot with Arduino Nano
  6. Ethernet-Driven Robot Arm: Remote Control Made Simple
  7. Bolt IoT Smart Robot Car – Arduino UNO & L298 Motor Drivers
  8. Smartphone‑Controlled Bluetooth Mouse: Build Your Own Virtual Joystick
  9. Bluetooth‑Controlled Pick‑and‑Place Robot Kit: Arduino UNO + 2‑DOF Arm & Smart Car Chassis
  10. Gesture‑Controlled Robot: Hands‑Free Arduino UNO Project