Build Android Bluetooth App for Arduino

by Abdullah_Al_Mamun_EEE_EWU_Bangladesh in Circuits > Robots

66352 Views, 72 Favorites, 0 Comments

Build Android Bluetooth App for Arduino

a.jpg

Hi, today i am going to make a android app for arduino Bluetooth module HC-06.Through this app you can control a light or led form your android phone.Lets do it..........

Go to Android Editor

a0.jpg

Go to MIT App Inventor

Link: http://appinventor.mit.edu/explore/

In the menu bar click on “Create App!”

Login using your gmail account.

If you don't have gmail account or Google Account.Then create an account.

Start Creating Android App

a1.jpg
a2.jpg
a3.jpg
a4.jpg

In the menu bar go to “Projects”.Click on it.You will see a drop down menu.In that drop down menu click on the “Start new project”.Then a page will came and want a project name.Give a project name.I give the project name "Bluetooth_Remot".Remember in this online editor you are not allow to give space in the name.So, i use this "_" .

Designer Page(Step-1)

a5.jpg

Now, you are in design page.In this page you will drag and draw the outer look of the app.

Designer Page(Step-2)

a6.jpg

From "Palette" in "User Interface" bar drag the "ListPicker" and drop it into the screen.

Designer Page(Step-3)

a7.jpg
a8.jpg

In the "Properties" bar change the name of this "ListPicker1" to "Connect".

Designer Page(Step-4)

a8.jpg
a9.jpg
a10.jpg

Like before from "Palette" in "User Interface" bar drag two "Button" and drop it into the screen.And from "Properties" bar change the name of that two Button "Text for Button1" and "Text for Button2" into "ON" and "OFF".

Designer Page(Step-5)

a11.jpg

Now, from "Palette" in "Connectivity" bar "BluetoothClient" and drop it into the screen.

Designer Page(Step-6)

a12.jpg

From "Palette" in "Sensors" bar "Clock" and drop it into the screen.

Shift Designer Page to Blocks

a13.jpg
a14.jpg

On the top click on the "Blocks" and you will get a new page like shown in the picture.

Blocks(Step-1)

a15.jpg

From "Blocks" to "Screen1" to "ListPicker1" click it and you will get boxes like the picture.Now Drag "When ListPicker1 .BeforePicking do" and drop into "Viewer".Again from that list drag "set ListPicker1 . Elements to" and drop it into "When ListPicker1 .BeforePicking do".That will looks like the picture.

Blocks(Step-2)

a16.jpg

From "Blocks" to "Screen1" to "BluetoothClient1" click it and you will get boxes like the picture.Drag "BluetoothClient1 . AddressesAndNames" into "set ListPicker1 . Elements to".

Blocks(Step-3)

a17.jpg
a18.jpg
a19.jpg
a20.jpg

Like Blocks(Step-1) and Blocks(Step-2) drag and drop like picture.

Blocks(Step-4)

a21.jpg

Like before from "Blocks" to "Screen1" to "Button1" drag "when Button1 . Click do" into "Viewer" .

Blocks(Step-5)

a22.jpg

From "Blocks" to "Screen1" to "BluetoothClient1" drag "call BluetoothClient1 . SendText text " into "Viewer" .

Blocks(Step-6)

a23.jpg

From "Blocks" to "Screen1" to "Text" drag " " " " into "Viewer".

Blocks(Step-7)

a24.jpg

Now in the text box in " " write "ON".

Blocks(Step-8)

a25.jpg
a26.jpg
a27.jpg
a28.jpg

Flow the same steps for "Button2" shown in pictures.Only change is write "OFF" in the box.

Download Your App

a29.jpg

Congratulation !!!!!!!!!!!!!!!! You just build your Bluetooth app.Now to download it go to top click on "Build" and then click on "App(save .apk to my computer)".

Arduino Program for This App

a30.jpg

Now you have your remote to control arduino led light in pin 13.By using this remote you can ON or OFF any thing that you want.Here the simple code for arduino to control pin 13 led.

Code:

String a;

int led = 13;// add the pin number that you want to control.

void setup()

{

Serial.begin(9600);

pinMode(led,OUTPUT);

}

void loop() {

while(Serial.available()){

a=Serial.read();

Serial.println(a);

if(a=="ON")

{

digitalWrite(led,HIGH);

}

if(a=="OFF")

{

digitalWrite(led,LOW);

}

}

}