loading

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.

HC-06>>>Arduino

VCC>>>>5v

GND>>>>GND

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 https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller&feature=search 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() {
  Serial.begin(9600);   
Serial1.begin(9600);   // put your setup code here, to run once:
}
void loop() {
  if(Serial1.available()){
   input = Serial1.read();
   if(input != 'S'){   
//Serial.println(input);
       if (isAlpha(input)){   
//Serial.println("alpha");
 switch(input){   
case 'S':
//commands for when "stop" is pressed on the bluetooth app
    break;
   case'F':    
//commands for when "Forward" is pressed
 break;   
case 'B':      
//commands for when "Back" is pressed
break;   
case 'L':
//commands for when "Left" is pressed
break;   
case'R':      
//commands for when "Right" is pressed
break;   
case 'G':      
//commands for when "Forward Left" is pressed
break;   
case 'H':      
//commands for when "Back Left" is pressed
break;   
case'I':      
//commands for when "Forward Right" is pressed
break;   
case 'J':     
//commands for when "Back Right" is pressed
break;   
// 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
 break;   
default:
  break;  
}   
}   
if (isDigit(input)||input == 58){ 
number = input; 
number = number - 48; 
//
Serial.println(number); 
//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.

About This Instructable

693views

10favorites

License:

More by Robotics Competition:Use of the L298 H-Bridge With Arduino Using a HC-06 Bluetooth Module to Get Inputs From an Android Phone If, For, While, Map, and Switch Cases 
Add instructable to: