Mobile Control LED(Arduino+Bluetooth Module)

by Kitu Singh in Circuits > Arduino

2215 Views, 11 Favorites, 0 Comments

Mobile Control LED(Arduino+Bluetooth Module)

Screenshot_2016-09-11-21-25-26 - Copy.png
Cloud 4G Star_20160911_212712.jpg

Hello,

In this instructable i will show how to control LED from Android phone using Arduino Uno Board and HC-05 Bluetooth module.

In this Arduino code is explained.

For Android code refer...

https://www.instructables.com/id/App-for-Mobile-Control-LEDArduinoBluetooth-Module

Requirements

FVMMTM6IAI1N5D6.LARGE.jpg
hc-05_2.jpg
Cloud 4G Star_20160912_001604.jpg

Hardware:

  • Arduino Uno board
  • Bluetooth Module(here HC-05)
  • LED
  • Male to Male wires
  • breadboard
  • Android Phone

Software

  • Arduino

Circuit

circuit.png

Make circuit as shown in diagram above.

Note: connect VCC and GND of bluetooth module to 5V and GND of Arduino respectively.

Arduino Code

You can download code (led.ino file)

code is to turn ON ,turn OFF and adjust the brightness of LED.

boolean led= false;
char command;
String string;
  void setup()
  {
    Serial.begin(9600);
    pinMode(6, OUTPUT);//connect led to pin 6
  }
  void loop()
  {
    if (Serial.available() > 0) //check for input data 
    {string = "";}
    
    while(Serial.available() > 0)
    {
      command = ((byte)Serial.read());
      if(command == ':')
      {
        break;
      }
      else
      {
        string += command;
      }
      delay(3);
    }
    
    if(string == "on")//as "on" is written in android app for turning on led
    {
       analogWrite(6, 255);
       delay(10);
       Serial.println(string);
       led = true;
    }
    
    if(string =="off")//as "off" is written in android app for turning on led
    {
         analogWrite(6, 0);
         delay(10);
         led = false;
         Serial.println(string);
    }
    
    if ((string.toInt()>=0)&&(string.toInt()<=255))
    {
      if (led==true)
      {
        analogWrite(6, string.toInt());//type casting to integer
        Serial.println(string);//printing the int value 
        delay(10);
      }
    }
 }

Downloads

Android App

Screenshot_2016-09-11-21-25-18.png
Screenshot_2016-09-11-21-25-22 - Copy.png
Screenshot_2016-09-11-21-25-26 - Copy.png
Cloud 4G Star_20160911_212647.jpg

Download the LED Control.apk from link given:

https://drive.google.com/open?id=0B4eY-jcXDOueX0M5...

  • Install the app
  • upload the code in Arduino (NOTE:keep recieving pin of arduino disconnected while uploading code)
  • OPen the app and enjoy controlling LED from mobile

If want to learn Android app code refer...

https://www.instructables.com/id/App-for-Mobile-Control-LEDArduinoBluetooth-Module

thank you.