Skip to content
MechStuff

MechStuff

''Making stuff… Simpler''

  • Home
  • MechStuff
  • News
  • How Stuff Works
  • Engines
  • Mech-Tech
  • TechStuff
  • Robotics
    • Robot Stuff
    • Tutorials
  • Engineering Marvels
  • For Mechanical Engineers
    • Games for Mechanical Engineers
    • Movies for Mechanical Engineers
    • Projects for Mechanical engineers
  • Contact Us
  • About us

Control LEDs with your Android | Arduino-Bluetooth module tutorial

28
Control led or any other stuff with android

You already know what we are gonna do today…so lets get started !

Things you’ll need :-

  • Arduino board
  • Breadboard
  • Bluetooth module/sensor – HC05
  • Couple of jumpers/single stranded wires
  • LEDs
  • An ANDROID(obviously 😛 )

Video tutorial down below↓

Connections Of Bluetooth module HC05 :-

VCC – to VCC of Arduino.
GND – to GND of Arduino.
RX – to digital pin 0(TX pin) of Arduino.
TX – to digital pin 1(RX pin) of Arduino. (connect RX & TX pin after uploading the code)

Of LED –
Positive terminal – to pin 8 of Arduino.
Negative terminal – GND of Arduino.



bluetooth module tutorial, connections, coding, arduino
Connections of bluetooth module HC05 with Arduino

Procedure :-

  1. Make the connections as shown in the above image. Don’t connect the RX & TX pins WHILE/BEFORE  uploading the code !
  2. Copy the code given below.
  3. Download the app called BlueControl (It’s free). Here is the link
  4. Open the app Blue control (It will automatically turn on the device’s Bluetooth). Go to options. Click on “Connect to Robot”. Choose the device – HC 05.
  5. When you are connecting to the Bluetooth module for the first time, it will ask you the password. Enter 0000 OR 1234.
  6.  When the device gets successfully paired with the sensor, the LED lights on sensor will start blinking at a slower rate than usual.
  7. DONE. Copy the code given below & test it out !

Code :-

void setup() {
Serial.begin(9600);
 pinMode(8, OUTPUT); // put your setup code here, to run once:
 }

void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available()>0)
   {     
      char data= Serial.read(); // reading the data received from the bluetooth module
      switch(data)
      {
        case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
        case 'd': digitalWrite(8, LOW);break; // when d is pressed on the app on your smart phone
        default : break;
      }
      Serial.println(data);
   }
   delay(50);
}

You may like it –

Control LEDs with Voice command (in 2 mins, just change code)

 

Here’s a video tutorial which will surely make your job easy… 🙂

You may like –

Make an Obstacle avoiding robot using Ultrasonic sensor (in 10 mins)

Comment below if you face any difficulties. I’ll solve them for you ASAP

Share this Stuff :

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • More
  • Click to email a link to a friend (Opens in new window)
  • Click to print (Opens in new window)

Related

Tutorials android, Arduino, bluetooth module, code, connections, diy, how to, philips hue, program, sensor, smartphone, testing

28 comments on “Control LEDs with your Android | Arduino-Bluetooth module tutorial”

  1. Mary says:
    May 13, 2017 at 12:00 AM

    Thank you for this tutorial, but I am facing a problem while applying this project.

    My circuit is connected as you connect and my code is the same, but when i press the button in my phone, Nothing happen 🙁

    Actually I change the default name and password for my Bluetooth module, I don’t know if this was the problem. Can you help me?

    Thank you

    Reply
    1. Jay Baviskar says:
      May 13, 2017 at 10:39 AM

      Hello Mary ! Check whether you’ve connected the RXD & TXD pins properly !
      Well, changing the name won’t affect the circuit, but if your connections are proper & code is correct, try reverting the module’s name back to the original/default one !

      Reply
  2. Himanshu says:
    May 20, 2017 at 2:14 PM

    Thank you for the tutorial..connections are same as you did, same code same app…But my led won’t turn on and off…and a on board Tx led is glowing as i’m pressing any buttons on the app…
    Waiting for the reply

    Reply
    1. Jay Baviskar says:
      May 22, 2017 at 10:03 PM

      Are you able to see the received values in the Serial monitor ?

      Reply
  3. avash says:
    June 16, 2017 at 9:39 PM

    i want to connect bluetooth modulo hc-05 with arduino mega 2560.in which pin i connect rx and tx pin.

    Reply
    1. Jay Baviskar says:
      June 21, 2017 at 10:14 PM

      Same pins – Digital pin 1 & 0 !

      Reply
  4. Jai says:
    July 1, 2017 at 12:39 PM

    Thanks for tutorial.
    I wanted to ask what does the break command do in the code?

    Reply
    1. Jay Baviskar says:
      July 2, 2017 at 8:09 PM

      The ‘break’ command ends the execution of the the nearest ‘do while’ OR ‘while’ statement.

      Reply
  5. ekatrina says:
    July 18, 2017 at 12:40 AM

    hi bro , im going to implement this on arduino nano , will it work?

    Reply
    1. Jay Baviskar says:
      July 21, 2017 at 10:16 AM

      Yes it will !

      Reply
  6. AryA says:
    September 7, 2017 at 12:24 AM

    Can Bluetooth module can give response to the Arduino when certain distance is covered that has been set by us

    Reply
    1. Jay Baviskar says:
      September 20, 2017 at 10:27 PM

      NO, unfortunately it cannot !

      Reply
  7. jacob says:
    September 20, 2017 at 7:10 AM

    Hello I’m Trying to control 5 LEDS and a Motor with bluetooth,can i achieve this by simply adding the pinModes and add switch data to more cases? Ex:

    switch(data)
    {
    case ‘a’: digitalWrite(8, HIGH);break;
    case ‘b’: digitalWrite(8, LOW);break;
    case ‘c’: digitalWrite(9,High);break;
    case’d’: digitalWrite(9,LOW);break;
    default : break;
    }

    and so on

    Reply
    1. Jay Baviskar says:
      September 20, 2017 at 10:26 PM

      Hi Jacob, yes, you can ! You can also use “if-else” statements instead. You are on the right track.

      Reply
  8. bharath says:
    November 6, 2017 at 6:26 AM

    Whether this can be used for starting car or not

    Reply
    1. Jay Baviskar says:
      November 6, 2017 at 10:13 PM

      Oh yes, why not ! Its just that, you may need a motor driver !

      Reply
  9. Phinie says:
    January 7, 2018 at 8:30 AM

    Hi, thank you for the tutorial. It’s clear and great.
    I first encountered the same problem that the led won’t glow. Then I found that was because of I had it reversely connected. So if anybody have the same problem may try to reconnect the led.

    Reply
  10. Lavinyaa Jayaraman says:
    September 5, 2018 at 8:53 AM

    Hi sir, actually im doing 3D 4x4x4 LED cube to my final project for interaction design but in all the youtube tutorial they use arduino nano to play the led but for my project we must use hc-06 for control with bluetooth so i dont know how to connect it with bluetooth control animation in mobile device?

    Reply
  11. Jonah Osterried says:
    March 17, 2019 at 5:46 PM

    How can I change on my Arduino pins the rx and tx pins to somewhere else? The Pin 0 & 1 is occupied by the tft screen. Can somebody help? I have tried everything.

    Reply
    1. Jay Baviskar says:
      March 24, 2019 at 10:58 AM

      Take the 2 pins of RX & TX and connect it to the breadboard. This way you can have multiple connections 😀

      Reply
  12. Sandeep says:
    March 28, 2019 at 5:08 PM

    My ultrasonic sensor not glow led according your YouTube vedio while connections and coding is write according you.

    Reply
    1. Jay Baviskar says:
      May 3, 2019 at 11:15 AM

      Hi Sandeep, try connecting the ultrasonic sensor directly with Arduino or on the different location on breadboard.

      Reply
  13. Shaik sahil says:
    August 24, 2020 at 10:30 PM

    According to your given code. It is saying that there is no member named avaliable. And also that there is no member named printIn. Please help me

    Reply
    1. Jay Baviskar says:
      September 16, 2020 at 7:13 PM

      Cn you send me your code & the error messages you recieved?

      Reply
  14. Arush Gupta says:
    September 25, 2020 at 2:18 PM

    You are giving power from laptop ? Can I give power through battery?

    Reply
    1. Jay Baviskar says:
      September 25, 2020 at 7:18 PM

      Yes, sure.

      Reply
  15. yaser says:
    October 8, 2020 at 9:59 PM

    Hi jay, when all done and uploaded, when i click ‘a’ the led glows but when i click ‘d’ the led does not turn off and remains on.

    Reply
    1. Jay Baviskar says:
      December 14, 2020 at 10:45 AM

      Most probably code issue, check that line properly again

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Idealist by NewMediaThemes