---
# System prepended metadata

title: Bluetooth Module
tags: [Arduino]

---

###### tags: `Arduino`
# Bluetooth Module
The Bluetooth module have two different model, **HC05** and **HC06**. The difference is the former can be set to Master or Slave, and the later can only be the Slave.

* pinout (6 pin type)
![](https://i.imgur.com/u55JEBZ.jpg =750x)

# Connect to the board
HC05/6 use the softwareSerial to communicate with Arduino board(just like the way Arduino communicate to PC). The pin can set connect to any teo digitalpins only not using D0 & D1. In the example, I use D9 & D10.

![](https://i.imgur.com/FaadEQ1.jpg =850x)

# Sample Code
Here is a simple code to test the connection between Arduino and HC05. Download [controller app](https://play.google.com/store/apps/details?id=com.giumig.apps.bluetoothserialmonitor) and open Bluetooth on your phone. Next, find HC05 and connect to it. The password could be 0000 or 1234. Then go to the app and tap the HC05 to connect it using Terminal mode. Now you can type letter and send to Arduino.
![](https://i.imgur.com/RgVoqwe.jpg =300x)![](https://i.imgur.com/OA1fGeC.jpg =300x)

![](https://i.imgur.com/0EbZ6I7.png =750x)

## code
```cpp=
#include <SoftwareSerial.h>

SoftwareSerial BT(9, 10);
//BT(RX pin, TX pin)
//TX on Arduino need to connect to RX on HC05, and so as RX on board an TX on HC05
void setup(){
    Serial.begin(9600);
    BT.begin(9600);
}

void loop(){
    if(Serial.available()){
        char a = Serial.read();
        BT.println(a);
    }
    if(BT.available()){
        char b = BT.read();
        Serial.println(b);
    }
    delay(100);
}
```
