Mobile Control LED(Arduino+Bluetooth Module)

by Kitu Singh in Circuits > Arduino

2364 Views, 11 Favorites, 0 Comments

Mobile Control LED(Arduino+Bluetooth Module)

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

Hardware:

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

Software

  • Arduino

Circuit

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

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.