PROFESSORHULKDhrumil Mistry
Published © GPL3+

Bluetooth Control Robot (Secured Bluetooth Connection)

We can control this bot by Bluetooth with a secured connection

IntermediateFull instructions provided5 hours719
Bluetooth Control Robot (Secured Bluetooth Connection)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
L293D Motor Driver/Servo Shield for Arduino
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Cligo 4WD ABS Smart Robot Car Chassis
×1
110 RPM Half Metal Gear BO Motor – Straight
×1
D65mm Rubber Wheel Pair - Blue (Without Shaft)
×1
18650 Battery Li-ion 3.7V Battery
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor
MIT App Inventor

Story

Read more

Custom parts and enclosures

APPLICATION TO CONTROL ROBOT

wheel_12mm_hex_adapter_dfrobot_afwwpazya3_gncuDuKH34.stl

Schematics

bluetooth_controlled_robot_bb_C4o3ZgDFx1.jpg

Code

Bluetooth_Controlled_Robot_ProfessorHulk.ino

C/C++
//Modied By ProfessorHulk And DM Dhrumil Mistry
//The One and Only Smasher Tech (TOAOST)
//Install AFMotor.h library before uploading code to Arduino Board

#include <AFMotor.h>

//initial motors pin
AF_DCMotor M1(1, MOTOR12_1KHZ); //M1 for Motor 1
AF_DCMotor M2(2, MOTOR12_1KHZ); //M1 for Motor 2
AF_DCMotor M3(3, MOTOR34_1KHZ); //M1 for Motor 3 
AF_DCMotor M4(4, MOTOR34_1KHZ); //M1 for Motor 4

String command; 
String passwd = "mypassword";



void forward()
{
  M1.setSpeed(255); //Define maximum velocity
  M1.run(FORWARD); //rotate the motor clockwise
  M2.setSpeed(255); //Define maximum velocity
  M2.run(FORWARD); //rotate the motor clockwise
  M3.setSpeed(255);//Define maximum velocity
  M3.run(FORWARD); //rotate the motor clockwise
  M4.setSpeed(255);//Define maximum velocity
  M4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
  M1.setSpeed(255); //Define maximum velocity
  M1.run(BACKWARD); //rotate the motor anti-clockwise
  M2.setSpeed(255); //Define maximum velocity
  M2.run(BACKWARD); //rotate the motor anti-clockwise
  M3.setSpeed(255); //Define maximum velocity
  M3.run(BACKWARD); //rotate the motor anti-clockwise
  M4.setSpeed(255); //Define maximum velocity
  M4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
  M1.setSpeed(255); //Define maximum velocity
  M1.run(BACKWARD); //rotate the motor anti-clockwise
  M2.setSpeed(255); //Define maximum velocity
  M2.run(BACKWARD); //rotate the motor anti-clockwise
  M3.setSpeed(255); //Define maximum velocity
  M3.run(FORWARD);  //rotate the motor clockwise
  M4.setSpeed(255); //Define maximum velocity
  M4.run(FORWARD);  //rotate the motor clockwise
}

void right()
{
  M1.setSpeed(255); //Define maximum velocity
  M1.run(FORWARD); //rotate the motor clockwise
  M2.setSpeed(255); //Define maximum velocity
  M2.run(FORWARD); //rotate the motor clockwise
  M3.setSpeed(255); //Define maximum velocity
  M3.run(BACKWARD); //rotate the motor anti-clockwise
  M4.setSpeed(255); //Define maximum velocity
  M4.run(BACKWARD); //rotate the motor anti-clockwise
} 

void stop_motors()
{
  M1.setSpeed(0); //Define minimum velocity
  M1.run(RELEASE); //stop the motor when release the button
  M2.setSpeed(0); //Define minimum velocity
  M2.run(RELEASE); //rotate the motor clockwise
  M3.setSpeed(0); //Define minimum velocity
  M3.run(RELEASE); //stop the motor when release the button
  M4.setSpeed(0); //Define minimum velocity
  M4.run(RELEASE); //stop the motor when release the button
}


void setup() 
{       
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop(){
  // command format
  // passwd/command/
  if(Serial.available() > 0){
    String recvd_passwd = Serial.readStringUntil('/');
    command = Serial.readStringUntil('/');
    stop_motors(); //initialize with motors stoped
    //Change pin mode only if new command is different from previous.   

    if (recvd_passwd == passwd){
      if (command == "F")       forward();
      else if (command == "B")  back();
      else if (command == "L")  left();
      else if (command == "R")  right();
     } else {
      Serial.println("Invalid Passwd! " + recvd_passwd);
    } 
  }
}

Bluetooth Controlled Bot

Credits

PROFESSORHULK

PROFESSORHULK

9 projects • 9 followers
Dhrumil Mistry

Dhrumil Mistry

2 projects • 1 follower

Comments