Using a HC-06 Bluetooth Module to Get Inputs From an Android Phone

Introduction: Using a HC-06 Bluetooth Module to Get Inputs From an Android Phone

A key element to any robot is the ability to control it. A robot that moves about requires a method of remote control. Three popular control methods include infrared remotes, radio frequency (often 2.4GHz or 5.8GHz) and Bluetooth. The first, infrared, is often not ideal as it is generally unreliable and only works over small distances within the line of sight. Radio frequency is an ideal system as it works over significant distances and is reliable. Although in the past radio controllers have been a more expensive option, there are now many decent quality remotes on the market for reasonable prices. For anyone looking into controllers, I would strongly suggest investing in a radio controller and receiver in the future. The beauty of Bluetooth, however, lies in its convenience. Bluetooth modules, such as the HC-06 may be picked up extremely inexpensively and allow beginners to control their creations right from their smartphones.

Step 1: Wiring Up the HC-06 to an Arduino

The HC-06 has 6 pins: wakeup, VCC, GND, TXD, RXD and State, but for this you will only need to use 4 pins, VCC, GND, TXD and RXD. Here is how you should connect the Bluetooth module to your Arduino.




TXD>>>> Pin 0 (RX)

Please note: While the HC-06 will tolerate 5V power, the RXD pin can only handle 3.3V. As the Arduino pins use 5V logic, wiring directly from the Arduino's output pins to the HC-06 may damage the Bluetooth controller.

In order to keep the voltage at safe levels, use a potential divider to connect the RDX pin to the Arduino's TX pin (Digital Pin 1).

RXD>>Potential divider>>TX

The HC-06 acts as a serial port through which you can send and receive data. By using a serial terminal or a Bluetooth customized application on your computer or phone, you can control and monitor your project. Before uploading any code to the Arduino, disconnect the HC-06 module, since it shares the tx/rx pins and will interfere with the upload. Connect it again once the code has been uploaded successfully.

Step 2: Setting Up Your Controller

I recommend using an android phone with Andi. Co's Arduino Bluetooth RC Car application available from the play store at result. Once you have downloaded the application, be sure to enable Bluetooth on your device.

Step 3: The Arduino Sketch

The Bluetooth RC Car application controller screen has a number of control buttons and toggles. Each button sends a unique character to the HC-06. This code will read the character sent via Bluetooth and analyze it. Build in sections of code in the relevant areas to run different functions depending on the input.

/* Developed by the Midlands Robotics Team*/<br>
char input;
int number; 
void setup() {
Serial1.begin(9600);   // put your setup code here, to run once:
void loop() {
   input =;
   if(input != 'S'){   
       if (isAlpha(input)){   
case 'S':
//commands for when "stop" is pressed on the bluetooth app
//commands for when "Forward" is pressed
case 'B':      
//commands for when "Back" is pressed
case 'L':
//commands for when "Left" is pressed
//commands for when "Right" is pressed
case 'G':      
//commands for when "Forward Left" is pressed
case 'H':      
//commands for when "Back Left" is pressed
//commands for when "Forward Right" is pressed
case 'J':     
//commands for when "Back Right" is pressed
// you may want to include other cases for values sent by the app.
 See the settings in the app for the other values sent.
case 'q':   
input = 58;  
//should return a numeric value that will be converted to the number 10 later in the sketch
if (isDigit(input)||input == 58){ 
number = input; 
number = number - 48; 
//Commands for when slider is moved (range 0-10)

Step 4: Putting It All Together

Once you use the previous sketch to find out which button is being pressed on your controller, you can decide what functions you would like your robot to carry out. Insert these into the code, upload the code to the Arduino and wire it all up. once the HC-06 is getting power, you can start the application and connect your phone to the HC-06 from within the app. You may control the app with touch or motion using your phone's accelerometers. Now you can build in remote control into all your robotic creations.

Be the First to Share


    • Micro:bit Contest

      Micro:bit Contest
    • Fashion Challenge

      Fashion Challenge
    • Metal Contest

      Metal Contest



    4 years ago

    If you don't have a resistor that is half the value of another (like 10K and 20K). Then you can use three resistors of the same value (e.g. 10K, 10K, 10K). Replace the 10K in the example above with two resistors in parallel, and replace the 20K in the example above with the third resistor.