How to connect HC-05 Bluetooth Module to Arduino


In this tutorial, you will learn how to integrate the HC-05 Bluetooth module with Arduino and control some DC motors from a Bluetooth app on your phone.


Category:  Arduino

Difficulty:  Beginner

Submitted by: Gideon

Date: 28th January, 2018


HC-05 bluetooth module is a wireless module at connect with bluetooth devices like andriod and with an interface, allows controls. This module is used in robotics, home automation and other interesting projects. There are other types of bluetooth module in the market  but HC-05 bluetooth module is easy to use and widely used. In this tutorial, we are going to control two dc motors connected to a motor driver wirelessly from an android up.


A bluetooth device has the ability to connect to a device at a time. There is always a master and slave. The slave connects to the master and receives data. The vice-versa happens with the HC-05 bluetooth module. The HC-05 bluetooth module has six pins. The pins are the ends of the module are not considered in this tutorial. The four pins in the middle are the GND(ground), VCC(+5v), TXD(transmit) and RXD(receive). The module uses AT commands for configuration. The transmit pin is used to send data to another device in the connection. The receive pin is the point where the module gets data from other devices.

These are the components that are used in this tutorial. This tutorial is linked with the motor driver tutorial


The module uses serial for communication. The arduino has a serial pins at pins 0 and 1. Instead of using these pins which usually prevents uploading during code editting, you use software serial. This library allows you to have a new set of serial pins using the normal GPIO pins. In this tutorial, we are using pin 7 as RXD and pin 8 as TXD. The motors  are connected to four digital and PWM pins( pin 3,5,6 and 9). In this setup an andriod app call bluetooth controller is used to send characters to the HC-05 bluetooth module, the arduino receives it and executes the appropriate action.

This is a fritzing picture of the set up


This is the setup of the tutorial


This is the arduino code that will run the setup

#include <SoftwareSerial.h>
SoftwareSerial myserial(7, 8);     
//download"bluetooth controller" form google play 
//insert the variables(a,b,c,d) in the code in the app at the Set key tap

int motor1a = 3; // pin number controlling motor one anticlockwise
int motor1c = 5;  //pin number controlling motor one clockwise
int motor2a =6  //pin number controlling motor two anticlockwise
int motor2c =9; //pin number controlling motor two clockwise

void setup()                    // run once, when the sketch starts
Serial.begin(57600);// opens the serial port
  myserial.begin(9600); //opens the l
  pinMode(motor1a, OUTPUT);
  pinMode(motor1c, OUTPUT);
  pinMode(motor2c, OUTPUT);
  pinMode(motor2a, OUTPUT);


void loop()
  myserial.println(" ON"); // test the bluetooth's connecton
  if (myserial.available()>0) {
    char b =; //read the input
    if (b == 'a') {       //in case of 'a' motor one moves anticlockwise
    if (b == 'b') { //in case of 'b' motor one moves clockwise
    digitalWrite(motor1c,LOW); // put motor one anticlockwise off
      digitalWrite(motor1a,HIGH);//in case of 'a' motor one moves clockwise
    if (b == 'c') { //
      digitalWrite(motor2a,HIGH); //in case of 'c' motor two moves anticlockwise
      dwigitalWrite(motor1a,LOW);// put motor one clockwise off
    if (b == 'd') {  
      digitalWrite(motor2a,LOW); // put motor two anticlockwise off
      digitalWrite(motor1a,HIGH);//in case of 'd' motor two moves clockwise

    if (b == 'e') { //incase of 'e' puts all motor rotations off



This is how the bluetooth controller at google play store looks



Thank you for going through this tutorial and we are highly excited because we have been able to help you breakthrough in this area. Visit our website to buy all the components that you need and we wish you a steady study.


This is the tutorials website for Invent Electronics. We are a top online retailer of electronics components, microcontrollers and sensors in Ghana. Besides providing customers with good quality electronic components we want to help them build great projects with the components they buy for us so we’ve put together a ton electronics resources, projects and tutorials on this site just for you!

Looking for electronic components to buy in Ghana?

Get all your sensors, electronic components, Arduinos, Raspberry Pi and other parts for your project at great prices from our online store.

Join Our Community

We’re more than just an electronics store. We are also a community of makers, engineers, enthusiasts and more. Join our community today, meet and learn from other people like you.

0 0 vote
Article Rating
Would love your thoughts, please comment.x