BLUETOOTH CONTROLLED ROBOT CAR USING ARDUINO

In this we will see how to take input from user and how to use Bluetooth controlled robot car using arduino according to the instruction received.

In this we can provide 5 instructions to robot to move, forward (f), backward (b), right turn (r), left turn (l) and stop (s).

REQUIRED HARDWARE

S.N.ComponentQuantity
1. Arduino UNO1
2. Bluetooth HC05 / HC061
3. DC motor 5V2
4.L293D IC or Module1
5. Jumper Wires30 (approx)

CIRCUIT DIAGRAM

BLUETOOTH CONTROLLED ROBOT CAR

CONNECTION TABLE

S.N. Arduino HC-05
1. + 5V + 5V
2. GND GND
3. Rx Tx
4. Tx Rx
S.N. Arduino L293D
1. Pin 6 IN4 (IC Pin 15)
2. Pin 7 IN3 (IC Pin 10)
3. Pin 8 IN2 (IC Pin 7)
4. Pin 9 IN1 (IC Pin 2)
5. + 5V EN1, EN2, VSS, VS (Pin 1,9,16,8)
6. GND GND (Pin 4,5,12,13)
S.N. L293D Motor
1. OUT 1 (Pin 3) Motor 1 Pin 1
2. OUT 2 (Pin 6) Motor 1 Pin 2
3. OUT 3 (Pin 11) Motor 2 Pin 1
4. OUT 4 (Pin 14) Motor 2 Pin 2

WORKING

  1. Download “robo car app” and make connection with Android  App.
  2. After successful Bluetooth connection made with mobile app
  3. Then set values for forward, backward, right and left buttons, same as you used in arduino code. For example, f for forward.
  4. Now user will click over forward button OR can send instruction ‘f’, using serial text box, which will be receive by microcontroller and to call forward function f(). This will move robotic car in forward direction. Once you release finger from forward button in app, motors will stop. 
  5. If you are using any other app then you need to send ‘s’ or any character to stop.
  6. User can also send  ‘b’ to move car in reverse / backward direction, ‘r’ for right direction and ‘l’ for left direction.

BLUETOOTH CONTROLLED ROBOT CAR USING ARDUINO

/* For Tutorial Click link: https://pijaeducation.com/arduino/bluetooth/bluetooth-controlled-robot-car-using-arduino/
 * Download android app: https://pijaeducation.com/download/
 */
int L1 = 9, L2 = 8, R1 = 7, R2 = 6;
void setup() {
  Serial.begin(9600);
  pinMode(R1, OUTPUT);
  pinMode(R2, OUTPUT);
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char c = Serial.read();
    Serial.print("INPUT : ");
    Serial.println(c);
    if (c == 'f') {
      Serial.println("FORWARD");
      f();
    }
    else if (c == 'b') {
      Serial.println("BACKWARD");
      b();
    }
    else if (c == 'r') {
      Serial.println("RIGHT");
      r();
    }
    else if (c == 'l') {
      Serial.println("LEFT");
      l();
    }
    else {
      Serial.println("Default");
      s();
    }

  } // END OF SERIAL AVAILABLE
} // END OF LOOP

void f() {
  digitalWrite(L1, HIGH);
  digitalWrite(L2, LOW);
  digitalWrite(R1, HIGH);
  digitalWrite(R2, LOW);
}
void b() {
  digitalWrite(L1, LOW);
  digitalWrite(L2, HIGH);
  digitalWrite(R1, LOW);
  digitalWrite(R2, HIGH);
}
void l() {
  digitalWrite(L1, LOW);
  digitalWrite(L2, LOW);
  digitalWrite(R1, HIGH);
  digitalWrite(R2, LOW);
}
void r() {
  digitalWrite(L1, HIGH);
  digitalWrite(L2, LOW);
  digitalWrite(R1, LOW);
  digitalWrite(R2, LOW);
}
void s() {
  digitalWrite(L1, LOW);
  digitalWrite(L2, LOW);
  digitalWrite(R1, LOW);
  digitalWrite(R2, LOW);
}

OUTPUT

In this we receive data in character form using function Serial.read(), you can use Serial.readString() if you like to receive String.

When we send character ‘f’ as a input it calls forward function f(), and moves forward as you  release forward key then motors stops moving.

You can send ‘b’ calls backward function b(), ‘r’ calls right function r() and ‘l’ call left function l().

Once you installed app (download app) & connect your phone with Bluetooth HC05 or HC06 and sets data you want to send from app. Then click forward, backward, right, left arrows to run motors or robot car.

Bluetooth Robot control
Click to zoom

 

Read Next: Bluetooth AT commands to change internal settings like, Bluetooth Name, Password and more

Total Visits: 1500
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Translate »
0
Would love your thoughts, please comment.x
()
x