Header Ads

Control Devices through Bluetooth Module HC05

Here we take an example of a Led to control it through Bluetooth Module - HC05

Control Devices through Bluetooth Module HC05

Component Required

  • Arduino Uno
  • Bluetooth Module HC05
  • Led
  • Jumper Wire
  • Smart Phone
  • Android App for Bluetooth Serial Communication

Arduino Code

int led = 3; // initialize pin 3 for led
void setup() 
{
  Serial.begin(9600); //baud rate 
  pinMode(led,OUTPUT); //set led pin as output
}

void loop()
{
  while(!Serial.available()); //it check continuously serial until it found 
  byte value = Serial.read(); //when data is found it will stored in variable 'value'
  switch(value)
  {
    case 'O':
      digitalWrite(led,HIGH); //when serial data is 'O' it will turn the On led
      Serial.print("Led is now turned On"); //it will print this message in Serial Monitor
      break;
    case 'F':
      digitalWrite(led,LOW); //when serial data is 'F' it will turn Off the led 
      Serial.print("Led is now turned Off"); //it will print this message in Serial Monitor
      break;      
  }
}

Note: This Arduino Code is also can be used for controlling any electronics and electrical components or appliances through Bluetooth or any Serial Control.

Schematic

Control Devices through Bluetooth Module HC05


No comments:

Popular Posts

Theme images by 5ugarless. Powered by Blogger.