Introduction: Arduino Bluetooth Basic Tutorial

Picture of Arduino Bluetooth Basic Tutorial

Ever thought of controlling any electronic devices with your smart phone ?Controlling your robot or any other devices with your smartphone will be really cool. Here is is a simple and basic tutorial for interfacing Bluetooth with arduino

Step 1: Things You Need

Picture of Things You Need

Hardware

Software

Step 2: Watch How Does It Works ?

Watch the video tutorial

Step 3: Let’s Start Building

Picture of Let’s Start Building

The circuit is so simple and small , there is only few connection to be made

Arduino Pins___________Bluetooth Module Pins

RX (Pin 0)___________________TX

TX (Pin 1)___________________RX

5V_________________________VCC

GND_______________________GND

Connect a LED negative to GND of arduino and positive to pin 13 with a resistance valued between 220Ω – 1KΩ. And your done with the circuit

Note : Don’t Connect RX to RX and TX to TX of Bluetooth to arduinoyou will receive no data , Here TX means Transmit and RX means Receive

Step 4: Upload the Code

/* Bluetooh Basic: LED ON OFF - Avishkar
* Coder - Mayoogh Girish
* Website - http://bit.do/Avishkar
* Download the App : https://github.com/Mayoogh/Arduino-Bluetooth-Basic
* This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
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
      Serial.print("\n");          //New line
      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
   }
}

Step 5: How Does It Works ??

Picture of How Does It Works ??

HC 05/06 works on serial communication.here the android app is designed sending serial data to the bluetooth module when certain button is pressed.The Bluetooth module at other end receive the data and send to ardunio through the TX pin of bluetooth module(RX pin of arduino).The Code fed to arduino check the received data and compares.If received data is 1 the LED turns ON turns OFF when received data is 0

Open the serial monitor and watch the received data

Step 6: Android Application

Picture of Android Application

In this tutorial I will not be covering tutorial on android app development.You can download the android application from here

How to use the app ?

Watch in video how to pair to bluetooth module
  • Download the Application from amazon app storeor here
  • Pair your device with HC 05/06 bluetooth module
    1) Turn ON HC 05/06 bluetooth module
    2)Scan for available device
    3)Pair to HC 05/06 by entering default password 1234 OR 0000
  • Install LED application on your android device
  • Open the Application
  • Press paired device

  • Select your Bluetooth module from the List (hc 05/06)

  • After connecting successfully

  • Press ON button to turn ON LED and OFF button to turn OFF LED

  • Disconnect button to disconnect from bluetooth module

This is just basic tutorial on interfacing bluetooth module with arduinoThis project can improved to higher level like Home automation using smartphone, Smartphone controlled robot and much more

For more cool DIY projects visit my Blog

Comments

udana (author)2017-07-08

Sir how to read data from arduino to via Bluetooth..(ex.temp valve )

your help much appreciated sir

MenasheU (author)2017-03-28

Very clear.

I wanted to ask if you know what should be done at the Android application level if want to add a switch that would also allow to manually switch on/off the led. And then my question is how to read the switch status ? (i.e. is it in a pressed state or not?)

FineVbF (author)2017-03-01

hi AVISHKAR .. can you do the code to upload in ATTINY85 ? support and aplication androit pleaseee... thank you .

amal_asaad35 made it! (author)2017-01-30

very easy and useful ...

thank you

chawla_mohali (author)2017-01-17

Good job. you kept it simple to understand!!

Cmp05 (author)2016-12-25

How about if i wanted it to unlock my car when i get near and lock as i walk away with bluetooh on my phone

NoffirmanV (author)2016-10-27

morning, want to ask, can nggk its bluetooth module in settings if clicking the connect / connect a bluetooth module with android android just close enough to the module, then connect automatically. thank you

NoffirmanV (author)2016-10-27

pagi master, mau tanya, bisa nggk modul bluetooth nya di setting jika meng konek kan/ menghubungkan modul bluetooth dengan android cukup mendekatkan android saja ke modul, maka terhubung secara otomatis. terima kasih

Dangerous33172 (author)2016-10-21

Hi, I was wondering if you can help me out? I want to make a bluetooth switch interface. It is like your project but different. Instead of the iphone being the switch, the switch is push device (3.5mm jack) connected to bluetooth and thru bluetooth acts as if your touching the screen. I wondering if I can set it up like this Mini USB Nano V3.0 ATMEGA328P Module CH340G 5V 16M Micro-controller board for Arduino with the Bluetooth HC-06 BLE and instead if leds like your project it will be 3.5mm jack. I added a link check it out, something similar of what I want to make but without a timer and just 2 jack
http://www.pretorianuk.com/applicator
Thank you any info is appreciated
Rodney @ dangerous33172@yahoo.com

Droxz made it! (author)2016-10-01

Hi,

Many thanks for sharing this info/instructable!

I'm working with a FTDI board + Arduino Pro Mini and i had to change the bitrate in the Arduino Serial Monitor to "19200". (default it's on "9600")

Installed the Android app, paired the HC-06 (in my case) and there is a message like "connected" but i can't press the "on" or "off" button in the app. I'm using Android 6.0.1 and it's not rooted or something. Any idea? :)

Any idea?

syaruls (author)2016-09-25

May i ask, i want to make the bluetooth seperation alert. using arduino nano and hc-06(non-BLE) or hc-08(BLE), when our smartphone and the bluetooth disconnects our smartphone will ring an alarm. can you give suggestions on programs and circuits on this project. thnx

PhongP10 made it! (author)2016-08-28

Thank you, your tutorial is very helpful and easy to follow!

PramodL made it! (author)2016-06-11

I made this project thanks for uploading but i didnt able to download the app so plz send me app file to my email id

PramodL (author)PramodL2016-06-11

limbolepramod007@gmail.com

hlin8 (author)2016-04-29

i like

nezmar007za (author)2016-04-29

Do I really need to use a resistor on pin 13?

Palms (author)nezmar007za2016-04-29

Sure you do. It prevents the LED to drain excessive current out of your Arduino pin...

nezmar007za (author)Palms2016-04-29

I just thought there is one buit-in on pin 13, but it seems like it was only in early Arduinos.

sambhu123 (author)2016-04-27

Can I Set Up A LED Bulb in this Thing?

Mayoogh_Girish (author)sambhu1232016-04-28

LED Bulb? Are you taking about AC bulb ? If yes it can Use a relay ,here is a tutorial to use relay 

instasquid (author)2016-04-24

I have everything set up right, my phone pairs with the Bluetooth device, but nothing happens when I press the buttons. Any idea what's going wrong?

Are you using the same code for arduino?

Yeah. I've changed the pin that the light is on because I'm using a Micro, but that's all.

instasquid (author)instasquid2016-04-25

I can't connect to it through a terminal either. Or it claims to have connected but entering 1 / 0 does nothing. I've disconnected it from the computer, so it's not that it's looking there for serial communication. I have 3 different HC-05 chips and they all share the same problem no matter if I try to connect with PC, Mac or Android.

Can you please upload the arduino sketch.
did you set the LED pin as OUTPUT pin? when you changed the pin.

Got it to work! Not 100% sure how, not complaining.

Thanks for the help!

I saw your code

there is small change


change if(Serial.available() 0) to if(Serial.available() > 0)

> is missing

rafaelnfs (author)2016-04-25

you dont use any library header just this :o

Mayoogh_Girish (author)rafaelnfs2016-04-25

there is additional library required for this

pvelazquez gomez (author)2016-04-24

Dude, could you make a tutorial to creat an App using Android Studio, pls. I have been looking for one but I didnt find. Pls. Or just upload de code

You can download the entire source code from here

Heyup (author)2016-04-25

This is great, thank you.

Does it matter if I purchase the Bluetooth receiver with 4 or 6 pins.

Thanks John :)

Mayoogh_Girish (author)Heyup2016-04-25

Its doesn't matter :)

Gorgoth (author)2016-04-24

Great app

I would recommend the MIT app inventor for anyone who finds working with the Android dev kit intimidating and want to do something more complicated its pretty easy to use if a little limited in some areas

kashif fiaz (author)2016-04-19

Where to upload the software?

Abdelali2 (author)kashif fiaz2016-04-24

https://github.com/Mayoogh/Arduino-Bluetooth-Basic

To Arduino,
It is programming platform used here

JetMechanic (author)2016-04-19

Is there a similar iPhone app?

kitefaster (author)JetMechanic2016-04-24

Check out this Light Show app for iOS. Here is a tutorial for it that uses BLE.

AlexJ2 (author)JetMechanic2016-04-24

Use the Evothings Viewer app, iOS applications in HTML5!

Any bluetooth serial communication app will work
after pairing just send 0 and 1 to turn LED ON and OFF

LightBlue
video

Abdelali2 (author)2016-04-24

nice . i think you can use the same app for turning ON/OFF a circuit ?

kashif fiaz (author)2016-04-19

Plz reply ,

To Arduino,

It is programming platform used here

kashif fiaz (author)2016-04-19

Where to upload the software?

kashif fiaz (author)2016-04-19

Where to upload the software?

kashif fiaz (author)2016-04-19

Plz reply ,

kashif fiaz (author)2016-04-19

Where to upload the software??

sukhpal35 (author)2016-04-19

very easy and nice tutorial. Thanks.

Mjtrinihobby (author)2016-04-18

really nice! I'm voting for this.

About This Instructable

53,612views

681favorites

License:

Bio: ignite.innovate.ideas
More by Mayoogh_Girish:Control AC light using ArduinoArduino Bluetooth Basic TutorialHand gesture controled robot
Add instructable to: