Circuit Creation

Bluetooth Control using Arduino (HC-05)

This project demonstrates how to control an LED wirelessly using a Bluetooth module (HC-05) and Arduino. You can send commands from your smartphone to turn devices ON or OFF, making it a great beginner IoT project.

Beginner

Components Required

Circuit Connections

Follow the steps below to connect the Bluetooth module and LED with Arduino.

  1. Connect HC-05 VCC to Arduino 5V.
  2. Connect HC-05 GND to Arduino GND.
  3. Connect HC-05 TX to Arduino RX (pin 0).
  4. Connect HC-05 RX to Arduino TX (pin 1).
  5. Connect LED positive to pin 8 through a 220Ω resistor.
  6. Connect LED negative to GND.

The Bluetooth module receives commands from your phone and sends them to Arduino, which then controls the LED accordingly.

Arduino Code

                
/*
   Project: Bluetooth LED Control using Arduino
   Description: Control an LED wirelessly using HC-05 Bluetooth module and Arduino. Send "1" to turn ON and "0" to turn OFF the LED.

   Components:
     - Arduino Uno 
     - HC-05 Bluetooth Module
     - LED 
     - 220Ω Resistor 
     - Breadboard 
     - Jumper Wires
     - USB Cable 
     - Smartphone with Bluetooth Terminal App
   Author: Circuit Creation RN

*/

// This code reads data from the Bluetooth module and controls an LED connected to pin 8 based on the received commands.


char data;

void setup() {
  pinMode(8, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    data = Serial.read();

    if (data == '1') {
      digitalWrite(8, HIGH);
    }
    else if (data == '0') {
      digitalWrite(8, LOW);
    }
  }
}
                

Upload the Code

  1. Disconnect HC-05 TX/RX before uploading.
  2. Upload the code using Arduino IDE.
  3. Reconnect Bluetooth module after upload.
  4. Pair HC-05 with your phone (password: 1234 or 0000).
  5. Use a Bluetooth terminal app to send "1" or "0".

Code Explanation

Serial Communication

Serial.begin(9600) starts communication between Arduino and Bluetooth module.

Reading Data

Serial.read() reads incoming data from the Bluetooth module.

Controlling LED

If the received data is '1', the LED turns ON. If it is '0', the LED turns OFF.

Common Mistakes & Troubleshooting

What You Learned