Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Arduino Bluetooth LED Control (HC-05 + SoftwareSerial)

This project demonstrates how to control an LED on an Arduino Uno using Bluetooth commands sent to an HC-05 module. The Arduino reads incoming characters through a SoftwareSerial interface and toggles a digital output pin accordingly.

Overview

The code configures a Bluetooth module (HC-05 or similar) on pins 10 (RX) and 11 (TX) and listens for single-character commands:

  • '1' → Turn LED ON
  • '0' → Turn LED OFF

The USB serial monitor displays each received character for debugging.

This project is useful for getting started with Bluetooth-based control systems, home automation prototypes, and remote device switching.

Features

  • Uses SoftwareSerial to communicate with the HC-05.
  • Prints received data to the Serial Monitor.
  • Controls an LED via simple character-based commands.
  • Fully compatible with Arduino Uno.

Hardware Requirements

  • Arduino Uno (or compatible board)
  • HC-05 Bluetooth module
  • LED + resistor (optional if using onboard LED)
  • Jumper wires

Wiring Diagram

Arduino Pin HC-05 Pin
10 (RX) TXD
11 (TX) RXD (via 3.3V logic divider recommended)
5V VCC
GND GND

LED wiring:

  • LED anode → Pin 8
  • LED cathode → Resistor → GND

Code Explanation

1. Library and SoftwareSerial Setup

#include <SoftwareSerial.h>
SoftwareSerial bt(10, 11); // RX, TX

Creates a software-based serial port for the HC-05.

2. Initial Configuration

void setup() {
  pinMode(8, OUTPUT);
  digitalWrite(8, LOW);
  Serial.begin(9600);
  bt.begin(9600);
  Serial.println("SLAVE READY");
}

Initializes Serial Monitor, the Bluetooth link, and sets pin 8 as the LED output.

3. Main Loop

void loop() {
  if (bt.available()) {
    state = bt.read();
    Serial.print("Received: ");
    Serial.println(state);

When a character is received, it is printed to the Serial Monitor.

4. LED Control Logic

    if (state == '1') {
      digitalWrite(8, HIGH);   // LED ON
    }
    else if (state == '0') {
      digitalWrite(8, LOW);    // LED OFF
    }
  }
}

Simple condition-based control toggles the LED depending on the command.

How to Use

  1. Upload the sketch to your Arduino.

  2. Pair your HC-05 with your phone or PC (default PIN: 1234 or 0000).

  3. Open any Bluetooth terminal app.

  4. Send:

    • 1 → LED ON
    • 0 → LED OFF

You should see “Received: X” in the Serial Monitor for every command.

Notes

  • Only one SoftwareSerial port can actively listen at a time on Arduino Uno.
  • Ensure the HC-05 RX pin receives 3.3V logic to avoid damage.
  • Baud rate must match the HC-05 data mode configuration.

License

This project is provided under the MIT License. You may use, modify, and distribute it freely.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages