Wednesday, July 4, 2018

Led On/Off using HC-05 Bluetooth Module & Arduino Uno


 
                  Led On/Off using HC-05 Bluetooth Module
                  & Arduino Uno
                 By Engr.Habib Ur Rehman


Components/Equipment Required:
            Following Components/Equipment are required to perform task.
2.    HC-05 Bluetooth Module (https://piees.pk/product/hc-05-bluetooth-module/)
3.    Smart Phone
5.    Breadboard
Circuit Diagram:

Arduino Program:
int ledPin=13;
int state=0;
int flag=0;
void setup()
{
 pinMode(ledPin,OUTPUT);
 digitalWrite(ledPin,LOW);
 Serial.begin(9600);
 }
 void loop()
 {
  if(Serial.available()>0)
  {
   state= Serial.read();
   flag=0;
   }
   if (state == '0')
   {
    digitalWrite(ledPin,LOW);
    if(flag==0)
    {
      Serial.println("LED: off ");
      flag=1;
      }
    }
    else if (state == '1')
   {
    digitalWrite(ledPin,HIGH);
    if(flag==0)
    {
      Serial.println("LED: on ");
      flag=1;
      }
    }
  }
Android Application:
            Android application is named as “Bluetooth Terminal HC-05”
            Pairing code is “1234”