Jon17

I'm quite new to the world of Arduino, but since the beginning I wanted to use my phone (an Android) to control my Arduino through Bluetooth. (I'm also a beginner to Android by the way).

I did tones of research online in order to find something relevant and simple in order to do that. But I miserably failed.But since patience is a virtue, I managed to gather information from almost everywhere and found this.

Without any pretension, here is a short how-to tutorial.Maybe this post will help, maybe not, but at least I tried ^_^.

You need a Bluetooth Adapter plugged to your Arduino obviously.For the Arduino code, I simply used the blink code and mixed it with Serial.read() function.http://arduino.cc/en/Serial/read

I'm not gonna explain how android works but here's the link to download the IDE.http://developer.android.com/sdk/index.html

Before anything, I want to add something, I'm not a pro in programming, like not at all, and I'm not a native English speaker, so I apologize for the mistakes I will make and for the non-scholarly terms I will use. (Remember that while reading, please).

Since I just want to use my App with my arduino, I hardcoded its Mac Address in the code.

First thing first you're gonna need to test if the bluetooth in your phone is enabled or not and if you can use it.

if (!mBluetoothAdapter.isEnabled()) {Toast.makeText(getApplicationContext(), "Bluetooth Disabled !",Toast.LENGTH_SHORT).show(); /* It tests if the bluetooth is enabled or not, if not the app will show a message. */}

public void Connect() {BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);Log.d("", "Connecting to ... " + device);mBluetoothAdapter.cancelDiscovery();try { btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);/* Here is the part the connection is made, by asking the device to create a RfcommSocket (Unsecure socket I guess), It map a port for us or something like that */btSocket.connect();Log.d("", "Connection made.");} catch (IOException e) {try {btSocket.close();} catch (IOException e2) {Log.d("", "Unable to end the connection");}Log.d("", "Socket creation failed");}beginListenForData(); /* this is a method used to read what the Arduino says for example when you write Serial.print("Hello world.") in your Arduino code */}

I took it online so I can't really tell you much about that other that it works.From what I can understand this method creates a Thread that checks whether there's something or not in the buffer and display it in the Result TextView.

Jon17

It might be a bit late, but the code goes in your Main Activity at least that's where I put it.If you want to learn more about Android Development, here's a pretty nice video tutorial :http://thenewboston.org/list.php?cat=6

The website covers lots of programming languages.(I don't own this website, nor i'm related to it, I just find it very good and pretty complete at least to start)

In addition, for those who might be interested, I used a Bt Adapter called JY-MCU, it's the cheapest one I could find on the bay.It works fine, it's a slave device though, so you can't scan nor initiate a connection with it.

I have only used AppInventor so far fr basic Android apps. It is simple to design a basic interface with a few buttons. Of course, you need to use proper development tools for larger projects. There is a free online course coming up on Coursera: for Android development that may be interesting: https://www.coursera.org/course/android

I started messing around with Bluetooth recently as well and created a small robot that I can control from my phone. I am documenting my progress here: http://42bots.com/tutorials/how-to-connect-arduino-uno-to-android-phone-via-bluetooth/

Electronic Technician, Electronic Engineering Technician
I love to build things. Test equipment, replica and original sci fi props and costume pieces, and whatever else I feel like at the time. I have an Ultimaker and a 3D engraver. I rarely put a kit tog

I'm very interested in this. I have several projects for the Arduino for which I need color screens, and having touchscreen controls would be a plus. Cheap Android tablets can be had for as low as $50, versus $80 or more for a 7 inch touchscreen.

At the moment, I have nothing more useful to add. I'm a rank newbie to Arduino programming, most of my programming experience was in solder and to a lesser extent in Basic.

pfodDesigner lets you build custom Android Menus and then generates the Arduino sketch that servers them up, via pfodApp, and handles the users button presses. You only need to add the action code to the sketch.

Here is an example menu designed by pfodDesigner. You can format the colour, text, number of buttons, font size and font style.No Android programming required.