Header Ads Widget

Responsive Advertisement

Arduino Bluetooth Basic Tutorial

 


 


This time ,i show the basic concept of arduino  

what is Microcontroller..?

              A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system(hardware + software ,our android mobile,laptops).

Difference between Microcontroller and Microprocesser:

         Two of them have many different ,in my understand ,is that microcontroller has no Operating System(computer  have OS). Instead, it uses thing called Firmware(, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware), that serves the same purpose as OS, but much simpler. It provides basic functionality over the device.

Arduino is 8-bit microcontroller
 

Things we need

    a. Bluetooth Module HC 05
    b. Arduino
    c. LED
    d. android device

1.Arduino IDE Software here 

2.Android app here 

How Does It Works..?

     HC-05 works on serial communication(serial communication is the process of sending data one bit at a time). we need to use this android app for  to send serial data to the Bluetooth module when a button is pressed. the bluetooth module receive the serial data comes from android app and its send to the arduino (pin tx ) then the arduino check the code
if the data is 1 -> trun on the light
if the data is 0 -> turn of the light

Code:

char data = 0; //Variable for storing received data
void setup()
{
    Serial.begin(9600); //Sets the baud for serial data transmission                              
    pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
   if(Serial.available() > 0)  // Send data only when you receive data:
   {
      data = Serial.read();        //Read the  incoming  data and store it into variable data
      Serial.print(data);          //Print Value inside data in Serial monitor
      if(data == '1')              // Checks whether value of data is equal to 1
         digitalWrite(13, HIGH);   //If value is 1 then LED turns ON
      else if(data == '0')   
      //  Checks  whether value of data is equal to 0
         digitalWrite(13, LOW);    //If value is 0 then LED turns OFF
   }
}

github-code

Code Explanation

char data=o;
we created a variable called data to store data received from the HS-05
void setup()
{
    Serial.begin(9600);
    pinMode(13, OUTPUT);
}


inside setup() Serial communication is initialized with a baud rate of 9600(baud rate means number of eletrical oscillations per second that occurs with data tansmissions,9600 bits per second its used in HS-05). The HS-05 Bluetooth module communicates to Arduino through serial communication.
pinMode(13, OUTPUT); sets digital pin 13 as OUTPUT pin. we are using a LED, which is an output device.


  if(Serial.available() > 0) 
   {
      data = Serial.read();
      Serial.print(data);


Serial.availabe() function return the number of character .
 if(data == '1')             
     {

 {   digitalWrite(13, HIGH); 
      else if(data == '0')       
         digitalWrite(13, LOW);
   }
}

if the value is greater than 0 which mean its receive the serial data ,the serial data is stored into the data variable
if the data varible is 1 its mean HIGH
if the data is 0 its mean LOW 

Connections


ARDUINO     BLUETOOTH
5V              ->  vcc
GND            ->  GND
TX              ->  RX
RX              ->  TX

ARDUINO     LED
GND            ->  -Ve
13              -> +Ve


step one
check the board what we use..?



we use uno so set it to uno
paste and save  the code 

 

verify the code  


upload the code to uno


 

Next  we use the android app to communicate to the arduino
download here
step1:
connect to the HS-05


step2:

 

we use the switch mode to connect to the bluetooth
step3:
i ,set 1 for on and 0 for off
the 1's and 0's are send it to the bluetooth and its send to  the arduino then arduino make a decision

 

 



Post a Comment

0 Comments