Introduction: Getting Started With HC-05
In this project, I have controlled a LED from a smartphone application connected via bluetooth (application developer project link). You need to have account on amazon playstore to download this application( link to download application )
HC-05 Module is a bluetooth module through which one can control sensors and LED wirelessly upto range of 10 meters. Default name of HC-05 module is HC-05 and password can be 0000 or 1234.
Important: - while uploading the code to arduino do not connect any pin to pin no 0 and pin 1. After uploading the code connect Rx and Tx of HC-05 module with pin0 and pin1 of Arduino.
Components Required
1. Arduino UNO - https://amzn.to/32jAMUA
2. LED - https://amzn.to/2RRwYE4
3. HC-05 module - https://amzn.to/3018IUs
4. Smartphone application - link to download application
5. Jumper cable - https://amzn.to/3iqdBxM
Step 1: Circuit Schematic
Connect Rx pin of Bluetooth to Tx pin of Arduino and Connect Tx pin of Bluetooth to Rx pin of Arduino but after uploading the code to Arduino other wise you will get the error while uploading your code.
Step 2: Arduino Code
char Incoming_value = 0; //Variable for storing Incoming_value
void setup() {
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
Serial.print("\n"); //New line
if(Incoming_value == '1') //Checks whether value of Incoming_value is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(Incoming_value == '0') //Checks whether value of Incoming_value is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
}