Bluetooth (HC05) and Arduino project: -
In this project i will teach you how to connect a Bluetooth module with Arduino and how to control each pin of Arduino with using your Phone.
Bluetooth HC05 or HC06: -
A Bluetooth module is a short range communication device which are capable of sending any kind of data in range of 15 to 20 meter and it's operating frequency band is 2.4GHz ISM band.Both are easily available things and can be obtain from near electronic shop or online stores.
1.1 Bluetooth HC-05 Pin-Out: -
·
KEY: If
brought HIGH before power is applied, forces AT Command Setup
Mode. LED blinks slowly (2 seconds)
· VCC: +5
PowerSupply.
GND: System
/ Arduino Ground.
TXD:
Transmit Serial Data from HC-05 to Arduino Serial Receive.
NOTE: 3.3V HIGH
level: OK for Arduino
· RXD: Receive
Serial Data from Arduino Serial Transmit
STATE: Tells
if connected or not
1.2 Bluetooth HC-05
Specifications: -
·
2.45Ghz Frequency
·
Asynchronous Speed 2.1Mbps
(max) .160Kbps
·
Security: Authentication
·
Profile: Bluetooth Serial Port
·
Power Supply: +3.3 V DC
·
Working Temperature: >20C
·
Cost: Around Rs. 300
2.
Component
required in this project: -
· Table of Component required: -
S no.
|
Component
|
Quantity
|
1
|
Arduino board
|
1
|
2.
|
Bluetooth HC05
|
1
|
3.
|
1k and 2k resister.
|
Each of one
|
4.
|
Android phone with ArduiDroid app
|
1
|
Figure 2: Component required in this project. |
3. ARDUINO interfacing with Bluetooth HC-05: - A Bluetooth model HC05 is device which can work in both master and slave mode. Pins connection of Arduino to Bluetooth is shown below.
Table
of connections: -
S no.
|
Bluetooth pins
|
Arduino pins
|
1.
|
Vcc.
|
+5v dc
|
2.
|
Gnd.
|
Gnd
|
3.
|
Tx.
|
Rx pin 0
|
4
|
Rx
|
Tx pin1
|
here are the link for component and other important things: -
ArduDroid App: - ArduiDroid app for Android Phone
Bluetooth HC05: - Bluetooth HC05 Data sheet pdf
Note: don't forget to use the resister in circuit, otherwise your Bluetooth module may get damage.
here is your code for controlling any digital pin of Arduino with you phone. copy the below code and enjoy it with you Bluetooth hc05.
void setup()
{
Serial.begin(9600);
Serial.println("HEllow frome Bluetooth");
Serial.flush();
}
void loop()
{
Serial.flush();
int pin_num = 0;
int pin_value = 0;
int get_char ='0';
if (Serial.available() < 1) return; // if serial empty, return to loop().
get_char = Serial.read();
pin_num = Serial.parseInt();
pin_value = Serial.parseInt();
set_digitalwrite( pin_num, pin_value);
}
void set_digitalwrite(int pin_num, int pin_value)
{
switch (pin_num)
{
case 13:
pinMode(13, OUTPUT);
digitalWrite(13, pin_value);
// add your code here
break;
case 12:
pinMode(12, OUTPUT);
digitalWrite(12, pin_value);
// add your code here
break;
//case 11:
// pinMode(11, OUTPUT);
// digitalWrite(11, pin_value);
// add your code here
// break;
//case 10:
//pinMode(10, OUTPUT);
// digitalWrite(10, pin_value);
// add your code here
// break;
case 9:
pinMode(9, OUTPUT);
digitalWrite(9, pin_value);
// add your code here
break;
case 8:
pinMode(8, OUTPUT);
digitalWrite(8, pin_value);
// add your code here
break;
case 7:
pinMode(7, OUTPUT);
digitalWrite(7, pin_value);
// add your code here
break;
case 6:
pinMode(6, OUTPUT);
digitalWrite(6, pin_value);
// add your code here
break;
case 5:
pinMode(5, OUTPUT);
digitalWrite(5, pin_value);
// add your code here
break;
case 4:
pinMode(4, OUTPUT);
digitalWrite(4, pin_value);
// add your code here
break;
case 3:
pinMode(3, OUTPUT);
digitalWrite(3, pin_value);
// add your code here
break;
case 2:
pinMode(2, OUTPUT);
digitalWrite(2, pin_value);
digitalWrite(2,HIGH);
delay(2000);
digitalWrite(2,LOW); // add your code here
break;
default:
return ;
// if nothing else matches, do the default
// default is optional
}
}
Further extension of this project:
in this project i have just introduce you to Bluetooth but there are some kind of different project can be made with you Bluetooth module and it capabilities are much more than this.
1. Serial massage and data can be send from phone to Arduino and Arduino to phone.
2.Any sensor can be connected to Arduino and could be control it with you phone with help of ArduiDroid app. like Servo, LED, motor, and any kind of Actuator and sensor.
Comments
Post a Comment