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.
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.
- 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.
- Arduino Uno (or compatible board)
- HC-05 Bluetooth module
- LED + resistor (optional if using onboard LED)
- Jumper wires
| 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
#include <SoftwareSerial.h>
SoftwareSerial bt(10, 11); // RX, TXCreates a software-based serial port for the HC-05.
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.
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.
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.
-
Upload the sketch to your Arduino.
-
Pair your HC-05 with your phone or PC (default PIN: 1234 or 0000).
-
Open any Bluetooth terminal app.
-
Send:
1→ LED ON0→ LED OFF
You should see “Received: X” in the Serial Monitor for every command.
- 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.
This project is provided under the MIT License. You may use, modify, and distribute it freely.