How to Use Arduino and Bluetooth Module to Control LED Project(DETAILED)
by avaqsemi in Circuits > Arduino
255 Views, 0 Favorites, 0 Comments
How to Use Arduino and Bluetooth Module to Control LED Project(DETAILED)
![Control The LED3.png](/proxy/?url=https://content.instructables.com/FQL/2QO4/LIVQ37DQ/FQL2QO4LIVQ37DQ.png&filename=Control The LED3.png)
In this article, I will demonstrate how to build an IoT project using Arduino (Arduino UNO) and Bluetooth module HC-05 to control LED lights. In this project, we will use an Android smartphone to send a bluetooth signal to a bluetooth module.
Supplies
- - Arduino UNO Motherboard
- - USB cable for connector Arduino UNO
- - Bluetooth module HC-05
- - Jumper wire male to female
- - LED
- - AC 220v/120v home appliance or 9v Hi-Walt battery
How Arduino Bluetooth Module Works
![How Arduino Bluetooth Module Works.png](/proxy/?url=https://content.instructables.com/FAH/0RDH/LIVQ36ZI/FAH0RDHLIVQ36ZI.png&filename=How Arduino Bluetooth Module Works.png)
In this project, three main components are used; Android smartphone, Bluetooth transceiver and Arduino.
The Android application can send serial data to the Bluetooth module HC-05 by pressing the ON button.The Bluetooth module HC-05 is used for serial communication. It receives data from the application and sends it to the RX pin of the Arduino via the TX pin of the Bluetooth module. the code uploaded in the Arduino checks the received data. If the received data is 1, the LED turns ON and if the received data is 0, the LED turns OFF.
Digital Circuit Diagram
![Digital Circuit Diagram.jpg](/proxy/?url=https://content.instructables.com/F7S/IONX/LIVQ370W/F7SIONXLIVQ370W.jpg&filename=Digital Circuit Diagram.jpg)
Bluetooth Module HC-05 Arduino UNO TX
--------------------------------> RX (Pin 0) RX
--------------------------------> TX (Pin 1) VCC
--------------------------------> 5v GND
--------------------------------> GND LED Pin Arduino UNO Pin 1
--------------------------------> GND Pin 2
--------------------------------> Pin 13
Launch Arduino Software
Write a program for Arduino UNO motherboard, if the received data is equal to 1, the LED is on, if the data is equal to 0, the LED is off. The reference code is as follows:
char data = 0; //Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the baud for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
if(data == '1') // Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') // Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
}
Save the Above Program and Compile It
![Save The Above Program And Compile It.png](/proxy/?url=https://content.instructables.com/FVN/WIT9/LIVQ377L/FVNWIT9LIVQ377L.png&filename=Save The Above Program And Compile It.png)
Connect the Arduino device to the laptop (or monitor) via the Arduino UNO USB cable. Remove all other connections from the Arduino UNO device (such as the Bluetooth module and LED) when uploading the program to Arduino UNO.
After compiling the code, upload it to the Arduino UNO device. Before uploading the code to Arduino, the UNO device ensures that the Arduino serial port is selected, otherwise an error message "Serial port not selected" will be generated.
To select the serial port, please open "Device Manager" -> "Ports" -> "Arduino Uno" and then upload the code.
Bluetooth Module to Connect Android Applications
![Search the Bluetooth device for pairing..png](/proxy/?url=https://content.instructables.com/FO8/H1CC/LIVQ37B7/FO8H1CCLIVQ37B7.png&filename=Search the Bluetooth device for pairing..png)
![Open the Bluetooth connector application, and then turn on Bluetooth for your device..png](/proxy/?url=https://content.instructables.com/F9K/D1O2/LIVQ37B8/F9KD1O2LIVQ37B8.png&filename=Open the Bluetooth connector application, and then turn on Bluetooth for your device..png)
![pair device.png](/proxy/?url=https://content.instructables.com/FXN/HQNU/LIVQ37B9/FXNHQNULIVQ37B9.png&filename=pair device.png)
![To pair with Bluetooth HC-05 module.png](/proxy/?url=https://content.instructables.com/FNU/HFC2/LIVQ37BA/FNUHFC2LIVQ37BA.png&filename=To pair with Bluetooth HC-05 module.png)
1. Open the Bluetooth connector application, and then turn on Bluetooth for your device.
2. Search the Bluetooth device for pairing.
3. To pair with Bluetooth HC-05 module, please enter :0000 or 1234.
4. Select the paired device HC-05 to connect to the Android application.
Control the LED Device
![Control The LED1.png](/proxy/?url=https://content.instructables.com/FPR/1VIL/LIVQ37CZ/FPR1VILLIVQ37CZ.png&filename=Control The LED1.png)
![Control The LED2.png](/proxy/?url=https://content.instructables.com/FJV/PYEU/LIVQ37D0/FJVPYEULIVQ37D0.png&filename=Control The LED2.png)
![Control The LED3.png](/proxy/?url=https://content.instructables.com/FRI/JOCK/LIVQ37D1/FRIJOCKLIVQ37D1.png&filename=Control The LED3.png)
When you click the "ON" button, it sends data 1 to the Bluetooth module, which is transferred from the Bluetooth module to the Arduino device, and turns on the LED. This data is transferred from the Bluetooth module to the Arduino and turns off the LED.