Thursday 7 September 2017

Bluetooth Basics : Arduino interface with HC05

We can control any of your electronic devices with your smart phone, Even we can control a robot or any other special electronic equipment with our smart phone , Here is a simple tutorial for interfacing an Android Smartphone with Arduino via Bluetooth

Required Materials


Hardware

  1. Bluetooth Module HC 05/06
  2. Arduino & Battery (with cable)
  3. LED
  4. 220Ω Resistor
  5. Android device
Software
  1. Arduino IDE
  2. Bluetooth electronics
Connecting the Arduino Bluetooth hardware



Arduino Code

char data = 0;                                      //Variable for storing received data
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())                     // Check if data available in serial port
      {
            data = Serial.read();               //Read the incoming data and store it into variable data
            if(data == 'a')                         //Checks whether value of data is equal to 1
            { 
              digitalWrite(13, HIGH);      //If value is 1 then LED turns ON
            }
            else if(data == 'b')                   //Checks whether value of data is equal to 0
            {
              digitalWrite(13, LOW);        //If value is 0 then LED turns OFF
            }
      }                            

}

Download Arduino code From here

No comments:

Post a Comment