Arduino HC-05 Bluetooth LED Control: Wiring, Code and Simulator
To build this Arduino HC-05 Bluetooth LED Control project you need an Arduino Uno and a Bluetooth HC-05, a 1 kΩ resistor and a 2 kΩ resistor. SoftwareSerial talks to an HC-05; pair from the Radio tab’s phone terminal and send 1 or 0 to switch the LED. Make the 7 connections in the wiring table, upload the Arduino C++ code, and open the Radio tab, press the HC-05 button to pair (PIN 1234), then send 1 and 0. Try PIN 0000 to see pairing refused.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | Bluetooth HC-05 | Bluetooth serial module: VCC 5 V, GND, TXD → the board’s RX pin, RXD ← the board’s TX pin (through a 1k/2k divider on a 5 V board). Starts at 9600 baud; hold EN high at power-up for AT commands at 38400. Pair it from the Radio tab’s phone terminal, or with a master HC-05 in another circuit (open it in a second tab). |
| 1 | 1 kΩ resistor | Limits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down. |
| 1 | 2 kΩ resistor | Limits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno 5V | Bluetooth HC-05 VCC |
| 2 | Arduino Uno GND | Bluetooth HC-05 GND |
| 3 | Arduino Uno pin 10 | Bluetooth HC-05 TXD |
| 4 | Arduino Uno pin 11 | 1 kΩ resistor leg 1 |
| 5 | 1 kΩ resistor leg 2 | Bluetooth HC-05 RXD |
| 6 | 2 kΩ resistor leg 1 | Bluetooth HC-05 RXD |
| 7 | Arduino Uno GND | 2 kΩ resistor leg 2 |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a Bluetooth HC-05, a 1 kΩ resistor and a 2 kΩ resistor from the parts palette.
- Wire 1. Connect Arduino Uno 5V to Bluetooth HC-05 VCC.
- Wire 2. Connect Arduino Uno GND to Bluetooth HC-05 GND.
- Wire 3. Connect Arduino Uno pin 10 to Bluetooth HC-05 TXD.
- Wire 4. Connect Arduino Uno pin 11 to 1 kΩ resistor leg 1.
- Wire 5. Connect 1 kΩ resistor leg 2 to Bluetooth HC-05 RXD.
- Wire 6. Connect 2 kΩ resistor leg 1 to Bluetooth HC-05 RXD.
- Wire 7. Connect Arduino Uno GND to 2 kΩ resistor leg 2.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Open the Radio tab, press the HC-05 button to pair (PIN 1234), then send 1 and 0. Try PIN 0000 to see pairing refused.
Arduino C++ code
// Bluetooth LED control with an HC-05.
// Pair from the Radio tab's phone terminal (PIN 1234), then send 1 or 0.
// Wiring: HC-05 VCC 5V, GND, TXD -> pin 10, RXD <- pin 11 through a 1k/2k divider.
#include <SoftwareSerial.h>
SoftwareSerial bt(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
bt.begin(9600); // the HC-05's default data-mode baud rate
pinMode(13, OUTPUT);
Serial.println("Waiting for a phone to connect...");
}
void loop() {
if (bt.available()) {
char c = bt.read();
Serial.print("Phone sent: ");
Serial.println(c);
if (c == '1') {
digitalWrite(13, HIGH);
bt.println("LED is ON");
} else if (c == '0') {
digitalWrite(13, LOW);
bt.println("LED is OFF");
}
}
// Anything typed in the serial monitor goes to the phone too.
if (Serial.available()) bt.write(Serial.read());
}
What to try
Open the Radio tab, press the HC-05 button to pair (PIN 1234), then send 1 and 0. Try PIN 0000 to see pairing refused.
Frequently asked questions
How do I wire the HC-05 Bluetooth LED Control project on an Arduino Uno?
Make 7 connections: Arduino Uno 5V to Bluetooth HC-05 VCC; Arduino Uno GND to Bluetooth HC-05 GND; Arduino Uno pin 10 to Bluetooth HC-05 TXD; Arduino Uno pin 11 to 1 kΩ resistor leg 1; 1 kΩ resistor leg 2 to Bluetooth HC-05 RXD; 2 kΩ resistor leg 1 to Bluetooth HC-05 RXD; Arduino Uno GND to 2 kΩ resistor leg 2.
What parts do I need for this Arduino project?
An Arduino Uno and a Bluetooth HC-05, a 1 kΩ resistor and a 2 kΩ resistor.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
SoftwareSerial talks to an HC-05; pair from the Radio tab’s phone terminal and send 1 or 0 to switch the LED.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator