Arduino projects make it possible to build your own custom electronics, but that doesn’t mean they can’t interact with your regular gadgets like your laptop or phone. With a simple module, you can add Bluetooth connectivity to your Arduino board and communicate with software you write yourself and make your projects even more advanced. In this guide, we’ll show how to connect your Arduino board to a Windows computer using a Bluetooth module.
While a few Arduino boards come with Bluetooth modules built in—for example, the Arduino BT—most don’t. In order to add Bluetooth capability to an Arduino project, you’ll need a separate module like the HC-05 we’ll be using in this guide. With just a few wires, you can connect a Bluetooth module and control your Arduino wirelessly.
The module uses two lesser-used pins on the Arduino: the TX and RX pins. These pins are used for serial communication, with the TX pin being used for transmission, and the RX pin is used for receiving. You might’ve used serial communication when connected to the computer via USB, but these pins allow another way to communicate with the Arduino without being physically connected.
This lets you send commands wirelessly to your Arduino from the computer, either using the serial monitor in the Arduino IDE or your own applications if you want to code your own. For this guide, we’ll show how to turn an LED connected to the Arduino on and off using typed commands from a Windows computer.
To make a start on your Arduino Bluetooth project, you won’t need many products. A simple Bluetooth module will do. While there are a few varieties of Bluetooth modules and shields for the Arduino platform on the market, we’ll be using the HC-05. Here’s the full list of what you’ll need:
Arduino Uno | ![]() |
Bluetooth HC-05 module | ![]() |
An LED | ![]() |
Wires & breadboard | ![]() |
USB cable | ![]() |
Arduino IDE | ![]() |
Once you have everything you need, move on to the code section to get started.
The full sketch for this project will let you send a text command from the serial monitor in the Arduino IDE to your project and turn on an LED. First, here’s the full code to get started:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include SoftwareSerial BT(1, 0); void setup() { pinMode(8, OUTPUT); BT.begin(9600); } char cmd; void loop() { if (BT.available()) { cmd=(BT.read()); if (cmd=='1') { digitalWrite(8, HIGH); BT.println(" LED on"); } if (cmd=='2') { digitalWrite(8, LOW); BT.println(" LED off"); } } |
Copy this code into your IDE and upload it to your Arduino board. Next, let’s look at some of the key points of this sketch line by line.
1 2 |
#include SoftwareSerial BT(1, 0); |
These two lines will include the SoftwareSerial.h library that makes it a little easier to communicate over the serial port. The second line will create a Bluetooth serial object named BT, that we’ll use later.
1 2 3 4 5 |
void setup() { pinMode(8, OUTPUT); BT.begin(9600); } |
In the setup section, we’ll assign the LED to pin 8, which we can use to turn the LED on and off. We’ll also start the BT object on the serial port.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
char cmd; void loop() { if (BT.available()) { cmd=(BT.read()); if (cmd=='1') { digitalWrite(8, HIGH); BT.println(" LED on"); } if (cmd=='2') { digitalWrite(8, LOW); BT.println(" LED off"); } } } |
The main loop of this sketch consists of a single conditional IF statement. If the Arduino detects the serial monitor, it will listen for commands. If you type “1” in the monitor, it will turn the LED on pin 8 on. If you type “2” in the monitor, it will turn the LED off. In both cases, it will also print a message to the serial monitor letting you know the code worked.
Connecting the HC-05 Bluetooth module is relatively straightforward. To connect the Bluetooth module to Arduino, follow these steps:
Once the wiring is connected, your HC-05 should be blinking rapidly, which indicates it’s discoverable by your computer. Now you’ll need to pair it with your computer.
To do this, open your computer’s Bluetooth settings page and search for available devices. You should be able to find an HC-05 device in the list. When you try to pair it, you’ll be asked for a pin. In most cases this should be either “1234” (as is the case for the HC-05) or “0000” but check the documentation for your module if you used something different.
Once that’s done, you’ll need to switch the serial monitor in the IDE to the correct COM port. You can find out which one is the correct one by opening the Bluetooth settings page in Windows 10, clicking “More Bluetooth options,” and selecting the “COM ports” tab. If the Bluetooth module and Arduino are successfully paired, you should see it here with the proper COM port listed next to it.
Go back to your Arduino IDE and under Tools > Port, select the COM port your Bluetooth module is connected to. Then, select Tools > Serial Monitor, and start typing commands. You can now control your Arduino remotely, completing this Arduino Bluetooth project. Try adding more LEDs and controlling them from different pins with additional commands next.