Drive Arduino Robot over Bluetooth with Android App

Serial port bluetooth, Drop-in replacement for wired serial connections, transparent usage. You can use it simply for a serial port replacement to establish connection between MCU and GPS, PC to your embedded project and etc.

Connecting the Bluetooth slave

! Disconnect RX en TX from bluetooth device when programming your Arduino !

Arduino Duemilanove HC-06 Bluetooth
3.3V VCC
GNC GND
RX TX
TX RX

*All other connections are optional.

Android control App

I used the Arduino BT Joystick App, it has a free and pro version,

ArduinoBTJoystickFreePro

The app can be downloaded from the official google play store:
Free version: Download Here
Pro : Download Here

Connecting via Bluetooth

Before connecting, make sure your device is connected and turned on,  a red led should be flashing when nothing is connected via bluetooth. On your android device, open your bluetooth settings:

arduinobtconnect1

Scan for bluetooth devices until you find your device in the list of available devices. To connect click the device in the list and enter the default pincode (usually 1234 or 0000)

arduinobtconnect2

When sucessfully connected, the device should say “Paired”:

arduinobtconnect3

Now open the BT Joystick app and click “Connect”, now fill in the exact name of your bluetooth device and hit connect:

arduinobtconnect4

The dialog should close and when connected, the led on the bluetooth module should stop flashing.

There are different modes available in this app, The best mode for robots is the “Drive” mode, however the joystick mode allows the same controls in a different layout.

Joystick in Normal Mode :

androidbtnormaljoystick

Joystick Mode: (Free + Pro app)

0 = no key pressed;
1 = UP key pressed;
2 = DOWN key pressed;
3 = LEFT key pressed;
4 = RIGHT key pressed;
5 = X button pressed;
6 = O key pressed;
7 = SQUARE button pressed;
8 = TRIANGLE button pressed;
9 = SELECT key pressed;
A = START key pressed;

void setup() {
  Serial.begin(9600); 
}

void loop() {
  //Read input from bluetooth module:
  if( Serial.available())
  {
    val = Serial.read();
  }
  //Input key switch
    switch (val) {
    case '0':    
      //Code when no key is pressed
      break;
    case '1':  
      //Code when UP key is pressed 
      break;
    case '2':    
      //Code when DOWN key is pressed 
      break;
    case '3':    
      //Code when LEFT key is pressed 
      break;   
    case '4':    
      //Code when RIGHT key is pressed 
      break;
    case '5':    
      //Code when X key is pressed 
      break;
    case '6':    
      //Code when O key is pressed 
      break;
    case '7':    
      //Code when SQUARE key is pressed 
      break;
    case '8':    
      //Code when TRIANGLE key is pressed 
      break;
    case '9':    
      //Code when SELECT key is pressed 
      break;
    case 'A':    
      //Code when START key is pressed 
      break;
    default:
      // default code (should never run)
    } 
  }
}
Joystick in Drive Mode :

Drive mode: (Free + Pro app)

0 = no key pressed;
1 = UP key pressed;
2 = DOWN key pressed;
3 = LEFT key pressed;
4 = RIGHT key pressed;
5 = X button pressed;
6 = O key pressed;
7 = SQUARE button pressed;
8 = TRIANGLE button pressed;
9 = SELECT key pressed;
A = START key pressed;

KEY COMBO ONLY IN DRIVE KEYS (Only in Pro version with multitouch enabled):
B = LEFT key pressed and UP key pressed;
C = LEFT key pressed and DOWN key pressed;
D = RIGHT key pressed and UP key pressed;
E = RIGHT key pressed and DOWN key pressed;

void setup() {
  Serial.begin(9600); 
}

void loop() {
  //Read input from bluetooth module:
  if( Serial.available())
  {
    val = Serial.read();
  }
  //Input key switch
    switch (val) {
    case '0':    
      //Code when no key is pressed
      break;
    case '1':  
      //Code when UP key is pressed 
      break;
    case '2':    
      //Code when DOWN key is pressed 
      break;
    case '3':    
      //Code when LEFT key is pressed 
      break;   
    case '4':    
      //Code when RIGHT key is pressed 
      break;
    case '5':    
      //Code when X key is pressed 
      break;
    case '6':    
      //Code when O key is pressed 
      break;
    case '7':    
      //Code when SQUARE key is pressed 
      break;
    case '8':    
      //Code when TRIANGLE key is pressed 
      break;
    case '9':    
      //Code when SELECT key is pressed 
      break;
    case 'A':    
      //Code when START key is pressed 
      break;
    case 'B':    
      //Code when LEFT+UP key is pressed 
      break;
    case 'C':    
      //Code when LEFT+DOWN key is pressed 
      break;
    case 'D':    
      //Code when RIGHT+UP key is pressed 
      break;
    case 'E':    
      //Code when RIGHT+DOWN key is pressed 
      break;
    default:
      // default code (should never run)
    } 
  }
}

Leave a Reply