Bluetooth Controlled Robot

Arduino Project Tutorial 16 : Bluetooth Controlled Robot (Using the G-sensor on Smartphone)

With G-sensor the robot will move depending on the slope of your smartphone.
Joystick can be operated in the normal mode by moving the slider with your finger.

- Hardware Required

Arduino Uno -
Bluetooth HC-06 -
DC Motor and Wheel -
Front Wheel -
F to F Wire -
M To M Wire -
Breadboard -
Battery 9V
9V Battery Clip -
9V Battery Cable -
Smartphone or Tablet

Recommended site -


- H-Bridge L293D

L293D is IC which is commonly used as a H-bridge. 
There are also other IC’s like L298 etc. but in this tutorial, we will see how we can use L293D.
At the same time, you can use Motor driver chip L298N in this project.

- Bluetooth Module

HC-06 chip of Bluetooth module solderes to the module board containing DC-DC converter and level conversion RX and TX signals.
Chip HC-06 needs power of 3.3V, but thanks to the converters, you can connect this module to the boards power by 5V.

- RemoteXY -

RemoteXY is easy way to make and use a mobile graphical user interface for controller boards to control via smartphone or tablet.

- Code
   -- New project --
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.2.5 or later version 
   download by link
   To connect using RemoteXY mobile app by link                   
     - for ANDROID 3.7.1 or later version;
     - for iOS 1.0.7 or later version;
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    

//        RemoteXY include library          //

// RemoteXY select connection mode and include library 
#include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings 

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 3,0,24,0,6,5,0,2,0,3
  ,0,5,16,42,10,40,40,2 };
// this structure defines all the variables of your control interface 
struct {

    // input variable
  uint8_t switch_1; // =1 if switch ON and =0 if OFF
  int8_t joystick_1_x; // =-100..100 x-coordinate joystick position
  int8_t joystick_1_y; // =-100..100 y-coordinate joystick position

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

//           END RemoteXY include          //

#define PIN_SWITCH_1 13

//define right motor control pins
#define right_motor_A 8
#define right_motor_B 9
#define right_motor_speed 11 //enable pin

//define left motor control pins
#define left_motor_A 6
#define left_motor_B 7
#define left_motor_speed 10 //enable pin

//define two arrays with a list of pins for each motor
uint8_t RightMotor[3] = {right_motor_A, right_motor_B, right_motor_speed};
uint8_t LeftMotor[3] = {left_motor_A, left_motor_B, left_motor_speed};

//speed control of motors
void Wheel (uint8_t * motor, int v) // v = motor speed, motor = pointer to an array of pins 
  if (v > 100) v=100;
  if (v < -100) v=-100;
  if (v > 0){

    digitalWrite (motor [0], HIGH);
    digitalWrite (motor [1], LOW);
    analogWrite (motor [2], v * 2.55);
  else if ( v<0 ){

    digitalWrite (motor [0], LOW);
    digitalWrite (motor [1], HIGH);
    analogWrite (motor [2], (-v) * 2.55);
    digitalWrite (motor [0], LOW);
    digitalWrite (motor [1], LOW);
    analogWrite (motor [2], 0);

void setup() 
  RemoteXY_Init (); 
  pinMode (PIN_SWITCH_1, OUTPUT);
  //initialization pins
  pinMode (right_motor_A, OUTPUT);
  pinMode (right_motor_B, OUTPUT);
  pinMode (left_motor_A, OUTPUT);
  pinMode (left_motor_B, OUTPUT);

void loop() 
  RemoteXY_Handler ();
  digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
  //manage the right motor
  Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x);
  Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x);