Arduino Robot Car Bluetooth Controlled

Arduino Robot Car Bluetooth Controlled

This project shows you how to make an Arduino Robot Car Bluetooth Controlled with Arduino, HC-05 Bluetooth Module, and L293D Motor Drive Shield. This is a unidirectional car with lighting. For more details, watch the below video or read the written below article.

Arduino Robot Car Bluetooth Controlled Using L293D

Component Required for Arduino Robot Car

Arduino Uno× 1Amazon
HC-05 Bluetooth Module× 1Amazon
L293D Motor Drive Shield× 1Amazon
TT Gear Motors× 4Amazon
Wheels× 4Amazon
18650 Battery Holder× 1Amazon
18650 Battery× 1Amazon
18650 Battery Charger× 1Amazon
Car Chassis Kit (TT Gear Motors, Wheels, 18650 Battery Holder, and Car Chassis)× 1Amazon
LED and Resistor Kit× 1Amazon
Buzzer× 1Amazon
Mini Breadboard× 1Amazon
Jumper Wires Kit× 1Amazon
USB Cable Type A/B× 1Amazon

Software

Arduino IDE

HC-05 Bluetooth Module

HC-05 is an easy-to-use Bluetooth SPP module optimized for smooth serial wireless communication configuration. Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with a total 2.4GHz radio transceiver and baseband. It uses a CSR Bluecore 04-External single-chip Bluetooth system with CMOS technology and AFH(Adaptive Frequency Hopping Feature). It has a compact footprint of 12.7mmx27mm.

HC-05 Bluetooth Module Default Settings

  • Default Bluetooth Name: “HC-05”
  • Default Password: 1234 or 0000
  • Default Communication: Slave
  • Default Mode: Data Mode

HC-05 Bluetooth Module  Specifications

Operating  voltage4V – 6V
Operating current consumption30mA
Range<100m
CostCheck price

The HC-05 is made by Itead Studio. For more information, you can check out the datasheet below:

L293D Motor Drive Shield

The L293D is a dedicated module that fits in the Arduino UNO R3 Board and the Arduino MEGA board. It is a motor driver shield with a full-featured Arduino Shield that can be used to drive 2 to 6 DC motors and 4 wire Stepper motors, as well as two sets of pins to drive a SERVO.

L293D Motor Drive Shield Specifications

Operating  voltage2.3V – 5.5V
Operating current consumption70 – 150 µA
Operating temperature40°C to +85°C
CostCheck price

The L293D Motor Drive Shield is made by Adafruit Industries. For more information, you can check out the datasheet below:

Arduino Robot Car Schematics

Arduino Robot Car Bluetooth Controlled Schematics
Arduino Robot Car Bluetooth Controlled Schematics

HC-05 Bluetooth Module Connections

HC-05 Bluetooth ModuleL293D Motor Drive Shield
VCC5V
GNDGND
TXDDigital pin 0
RXDDigital pin 1

LED and Buzzer Connections

The positive or big terminal of Front Left LED, Front Right LED, Back Right LED, Back Left LED and Buzzer connect with A0, A1, A2, A3, and A4 of the L293D Motor Drive Shield respectively. Negative or small terminal connect with GND.

Libraries for this Arduino Project

To install the library, you can download them from here. Next, go to Sketch > Include Library > Add .ZIP Library… in the Arduino IDE.

Arduino Robot Car Source Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/******** www.arduinopoint.com *****************************/
/******** Arduino Bluetooth Controlled Robot Car ***********/
// Inclue this libary
#include <AFMotor.h>
#define light_FR  14    //LED Front Right   pin A0 for Arduino Uno
#define light_FL  15    //LED Front Left    pin A1 for Arduino Uno
#define light_BR  16    //LED Back Right    pin A2 for Arduino Uno
#define light_BL  17    //LED Back Left     pin A3 for Arduino Uno
#define horn_Buzz 18    //Horn Buzzer       pin A4 for Arduino Uno

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

int command; //Int to store app command state.
int speedCar = 255; // Initial car speed set 0 to 255.
boolean lightFront = false;
boolean lightBack = false;
boolean horn = false;
void setup()
{
    pinMode(light_FR, OUTPUT);
    pinMode(light_FL, OUTPUT);
    pinMode(light_BR, OUTPUT);
    pinMode(light_BL, OUTPUT);
    pinMode(horn_Buzz, OUTPUT);

    Serial.begin(9600);

  Stop();
}

void forward()
{
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
    motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor3.setSpeed(speedCar);
  motor4.setSpeed(speedCar);
}

void backward()
{
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor3.setSpeed(speedCar);
  motor4.setSpeed(speedCar);
}
void left()
{
  motor1.run(FORWARD);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(FORWARD);
  motor1.setSpeed(speedCar);
  motor4.setSpeed(speedCar);
}
void right()
{
  motor1.run(RELEASE);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(RELEASE);
  motor2.setSpeed(speedCar);
  motor3.setSpeed(speedCar);
}

void forwardRight()
{
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(RELEASE);
  
  motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor3.setSpeed(speedCar);
}

void forwardLeft()
{
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(RELEASE);
  motor4.run(FORWARD);
  
  motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor4.setSpeed(speedCar);
}
void backwardRight()
{
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(RELEASE);
     motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor3.setSpeed(speedCar);
}
void backwardLeft()
{
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(RELEASE);
  motor4.run(BACKWARD);
  motor1.setSpeed(speedCar);
  motor2.setSpeed(speedCar);
  motor4.setSpeed(speedCar);
}
void Stop()
{
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
}

void loop(){
  
if (Serial.available() > 0) {
  command = Serial.read();
  Stop();       //Initialize with motors stopped.

if (lightFront) {digitalWrite(light_FR, HIGH); digitalWrite(light_FL, HIGH);}
if (!lightFront) {digitalWrite(light_FR, LOW); digitalWrite(light_FL, LOW);}
if (lightBack) {digitalWrite(light_BR, HIGH); digitalWrite(light_BL, HIGH);}
if (!lightBack) {digitalWrite(light_BR, LOW); digitalWrite(light_BL, LOW);}
if (horn) {digitalWrite(horn_Buzz, HIGH);}
if (!horn) {digitalWrite(horn_Buzz, LOW);}

switch (command) {
case 'F':forward();break;
case 'B':backward();break;
case 'L':left();break;
case 'R':right();break;
case 'I':forwardRight();break;
case 'G':forwardLeft();break;
case 'J':backwardRight();break;
case 'H':backwardLeft();break;
case 'S':Stop();break;
case '0':speedCar = 0;break;
case '1':speedCar = 25;break;
case '2':speedCar = 50;break;
case '3':speedCar = 75;break;
case '4':speedCar = 100;break;
case '5':speedCar = 125;break;
case '6':speedCar = 150;break;
case '7':speedCar = 175;break;
case '8':speedCar = 200;break;
case '9':speedCar = 225;break;
case 'q':speedCar = 255;break;
case 'W':lightFront = true;break;
case 'w':lightFront = false;break;
case 'U':lightBack = true;break;
case 'u':lightBack = false;break;
case 'V':horn = true;break;
case 'v':horn = false;break;
}}}

This Post Has 2 Comments

  1. Md. Sajidur Rahman

    amazing……
    please cost for this project total????

    1. Arduino Point

      Thanks for your asking. The cost for this project is around 18 dollars.

Leave a Reply