Skip to main content

Android app control LED

Project Name:-Android app control LED via bluetooth communication


Today i am going to control LED by Android app through Bluetooth communication.

Component required

  1. computer
  2. arduino with cable
  3. Bluetooth module (HC-05)
  4. RGB led
  5. android phone 



And a software named arduino ide in computer.
According to Wikipedia"Bluetooth is the wireless technology standard for exchanging the data over a short distance (using a short wave length) from the fixed and the mobile device and building the personal area networks(PANs)"
Bluetooth Module HC-05 is  easy to use serial port protocol ,designed for wireless serial connection to exchange the data.
Fig :- Bluetooth module HC-05

We need controller or transmitter to send the command to the receiver (i.e HC-05 module), here we use android app "Bluetooth terminal" in android phone to send the command to HC-05 module via Bluetooth connection.
download the Bluetooth terminal from play store.

Circuit
fig bluetooth module HC-05 interfacing with arduino
connect the tx and rx pin to 10 and 11 pin of an arduino ashown in figure connect an 
RGB led in any pin for example, let it is connect in pin no. 5,6 and 7.

Code
#include <SoftwareSerial.h>
int led1=5;
int led2=6;// pin define
int led3=7;
SoftwareSerial myserial(10,11);
void setup() {
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
Serial.begin(9600);
myserial.begin(9600);
myserial.println("connect A B C or any other");
// put your setup code here, to run once:

}


void loop() 
{
  if (myserial.available()) 
    {
      int val=myserial.read();
    Serial.println(val);

if(val=='a')
    {
      digitalWrite(led1,HIGH);
      digitalWrite(led2,LOW);
      digitalWrite(led3,LOW);
      Serial.println("a");
    }
    else if(val=='b')
    {
      digitalWrite(led1,LOW);
      digitalWrite(led2,HIGH);
      digitalWrite(led3,LOW);
      Serial.println("b");
    }
    else if(val=='c')
    {
      digitalWrite(led1,LOW);
      digitalWrite(led2,LOW);
      digitalWrite(led3,HIGH);
      Serial.println("c");
    }
    else
    {
      digitalWrite(led1,HIGH);
      digitalWrite(led2,HIGH);
      digitalWrite(led3,HIGH);
      Serial.println("other alphabet");
    }
  }
}
Now connect the phone to the system via bluetooth communication.
Then if we enter input ''a" then only led1 will ON,similarly, for B led2 will ON and for C led3 will ON.


Popular posts from this blog

SMPS of computer

                                            fig:- working principle of SMPS       fig :- SMPS of computer From the above figure, we came to know that the function of SMPS in computer which is to convert  the high 220V-AC to 0-12V DC.SMPS contain several color of wires which carry the different voltage to the different parts of the computer.The following table shows the different color cables and its carrying voltage.      

warm clothes distribution program

‘ Small step can make a big difference ’ Rural Women Development Centre from morang,Nepal distributed the warm clothes to the needy people. They manage it possible by collecting fund from working staffs and management committe. Here is the video link of the distribution program. https://youtu.be/AxaHbivcQUM

Multiple mcp23017 interfacing with Arduino

MCP23017 is the I/O port extender that runs on 12C. It is 16-bit I/O expender.in this tutorial we are going to interface the single and multiple  mcp23017 with arduino.  fig:- mcp32017 module IT has 16 I/O ports from PA0 to PA7 and PB0 to PB7. first of all we are going to interface the single mcp23017 with Arduino. For this  connect the circuit as shown on figure. Download the library for mcp23017  from  sketch-- include library -- manage libraries.