Bluetooth interfacing with arduino


Bluetooth interfacing with Arduino


Components require:

  • Arduino uno
  • HC06/HC05
  • Connecting cables
  • Red LED
  • 1k Resistor

Example projects:

  • ROBOT controlling with app
  • Home automation with app
  • 2 arduino communication
  • RGB color change of LED

Connections:

  • VCC=5v
  • GND=GND
  • RX=Tx
  • Tx=Rx
  • key=keep Open
  • State=keep Open

To learn how to interface led with Arduino


LEARN LED INTERFACING WITH ARDUINO

Arduino Code:

/*
It's a simple sketch which waits for a character on serial
and in case of a desirable character, it turns an LED on/off.

Possible string values:
a (to turn the LED on)
b (tor turn the LED off)
*/
char junk;
String inputString="";

void setup()
// run once, when the sketch starts
{
Serial.begin(9600);
// set the baud rate to 9600, same should be of your Serial Monitor
pinMode(13, OUTPUT);

}
void loop()
{
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{
junk = Serial.read() ;
}
// clear the serial buffer
if(inputString == "a")
{
//in case of 'a' turn the LED on
digitalWrite(13, HIGH);
}
else if(inputString == "b")
{
//incase of 'b' turn the LED off
digitalWrite(13, LOW);
}

inputString = "";
}

}

Bluetooth is the communication protocol and we are using this protocol to communicate our smart phone with arduino device. When we send character 'a' using our mobile app arduino sense it with help of HC05/06 and react with that command,What ever operations are assigned to receiving command that will come into work.
If any PROBLEM you are facing with that code ,please mention in command box.I will replay you as fast as possible.

Comments

Popular posts from this blog

Analog input Analog output of arduino

Arduino basic:How to get sub string from a string in arduino