This tutorial explains how to control device from a smart phone or any other bluetooth enabled device using a Bluetooht as a communication medium. We are using HC-06 Blue tooth module.
1. Introduction:
This tutorial explains how to control devices using HC-06 bluetooth module.
1.1 HC-06 Module:
A widely available bluetooth module that has capability to enable your project with bluetooth. It has got 6 pins interface. But we are interfacing it by using its four pins only. We are using-
- VCC – To supply +5V
- GND – To make it Ground
- TXD – Data TX pin
- RXD – Data Rx Pin
It has got one LED, Which shows its state. If it is blinking that means it is not connected. If it is staying in glowing condition that means it is connected. There is a pin STATE that is connected to this state LED. You may use this pin in your project to determine the state of BT module. This module look like this –
2. Required Hardware
Following Hardware will be required to perform this sketch of shift register.
S.No. | Item | Quantity |
1. | R-Board with FTDI or Arduino Board | 1 |
2. | HC-06 Bluetooth Module TTL | 1 |
3. | Male to female Jumpers | 4 |
3. Building Circuit
Make following circuit with the help of above mentioned components. We have included two examples here both of them use the following circuit.
3.1 You may go with Robo India’s R-Board(UNO Compatible)-
or
3.2 You may go with original Arduino UNO Board-
4. Programming:
Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section.
You may download this code (Arduino Sketch) from here.
// Bluetooth Tutorial By Robo India // Bluetooth module used - HC-06 #include <SoftwareSerial.h> SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06 char BT_input; // to store input character received via BT. void setup() { pinMode(13, OUTPUT); // Arduino Board LED Pin BlueTooth.begin(9600); } void loop() { if (BlueTooth.available()) { BT_input=(BlueTooth.read()); if (BT_input=='a') { digitalWrite(13, HIGH); BlueTooth.println("Now LED is ON"); } else if (BT_input=='b') { digitalWrite(13, LOW); BlueTooth.println("Now LED is OFF"); } else if (BT_input=='?') { BlueTooth.println("Send 'a' to turn LED ON"); BlueTooth.println("Send 'b' to turn LED OFF"); } // You may add other if else condition here. } }
6. Application on Phone:
Download any Bluetooth Terminal on your smart phone. We have tested this with “Bluetooth Terminal” By QWERTY.
1. Download Bluetooth terminal application.
2. Pair your phone with HC-06. for doing this go to Settings->Bluetooth->Scan device->select HC-06 and pair it. Pass code to pair is ‘1234’.
3. Open Bluetooth Terminal software, go to options and select ‘connect a device – secure’ option. It ask for pass code enter 1234. Here is the screen shot of phone with this application.
If you send ‘a’ it will make to LED (Connected on D-13) ON and if you send ‘b’ it will make the LED OFF. The Arduino code also sends the current state of LED also. If you send ‘?’ it will send the instruction. The following video will clear these understandings.
6. Output:
Here is the output of the above code and circuit.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
http://roboindia.com