Bluetooth controlled robot car Using Arduino

In this we will see how to take strings from user and Bluetooth controlled robot car using arduino according to the instruction received. In this we are providing three instructions to robot

  1. First one is to move forward
  2. Second one is to move reverse
  3. Third one to stop or hold the robot


#define del 2000

// Set pin number
int motor1Pin1 = 8;
int motor1Pin2 = 9;
int motor2Pin1 = 6;
int motor2Pin2 = 7;

String input_string;

void setup() {
  // Set the pins as output
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin1, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);

  // Initialize serial communication at 9600 bits per second

void loop() {
  // To check if data is available on Serial port
  if (Serial.available() > 0) {
    // To read a data from HC05 via serial communication protocol
    input_string = Serial.readString();
    if (input_string == "forward") {
    else if (input_string == "reverse") {
    else if (input_string == "hold") {


void forward() {
  digitalWrite(motor1Pin1, HIGH);
  digitalWrite(motor1Pin2, LOW);
  digitalWrite(motor2Pin1, HIGH);
  digitalWrite(motor2Pin2, HIGH);
  Serial.println("Forward! status");

void reverse() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH);
  digitalWrite(motor2Pin1, LOW);
  digitalWrite(motor2Pin2, HIGH);
  Serial.println("Reverse! status");

void hold() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH);
  digitalWrite(motor2Pin1, LOW);
  digitalWrite(motor2Pin2, HIGH);
  Serial.println("stop! status");



S.N. Arduino HC-05
1. + 5V + 5V
3. Rx Tx
4. Tx Rx
S.N. Arduino L293D
1. Pin 6 IN4 (Pin 15)
2. Pin 7 IN3 (Pin 10)
3. Pin 8 IN2 (Pin 7)
4. Pin 9 IN1 (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


  1. After successful connection made with mobile phone
  2. User will send instruction in the form of string like “forward”, which is then received by microcontroller and check it in If condition and call function made by us forward(), this will move robotic car in forward direction and after a delay of 2000 millisecond we call another function hold so that it will not stuck with the boundary
  3. You can change the value of delay
  4. Or you can remove hold and delay function and left for user to send “hold” as a string to stop
  5. User can also send string “reverse” to move car in reverse direction.


In this we can send data in String form using function Serial.readString(). When we send “forward” as a string it calls forward function and moves forward then automatically stops the motors by calling hold function & when we send “reverse” as a string it calls reverse function and moves backward then automatically stops the motors by calling hold function.

output Robot control

Leave a Reply

Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »