About half a year ago I programmed a small app for Android that communicates with an Arduino over Bluetooth (http://coretechrobotics.blogspot.com/2013/12/controlling-arduino-with-android-device.html). It had some very basic features and a simple user interface, which was just enough for the project it was designed for. But no two projects are alike.
Because of that I decided to make a universal remote that would be customizable to all possible applications.
The main idea is that the user should be able to create his own remote, without having to learn java programming. This would require the app to have some kind of built in editor.
Another part is Multitouch, which is essential for any touchscreen application. It seems to be simple at first but as I knew from my previous attempt at an android app, this makes things extremely complicated. Imagine you don’t just have an X/Y position of your mouse pointer but a whole array of those.
Instead of finally learning how to program in pure Java I went with Processing again. This helped me a lot and reduced the time I had to spend on the project.
At first I needed Multitouch. This was a difficult part, I had to read through a lot of Android documentation and Internet articles until it finally worked. Maybe I will write a separate Post about this in the near future.
The next step were proper UI elements like sliders and buttons. My previous app used the controlP5 library by Andreas Schlegel (http://www.sojamo.de/libraries/controlP5/). But I wanted something of my own. I chose to write a UI library from scratch, with a simple edgy design and full Multitouch integration. The four UI elements are sliders, joysticks (2D-Sliders), buttons and switches.
The editor is the main part of the app, from there the user can drag and drop the elements on the screen. The size and position can be changed by moving its center or corner.
The color can be selected in a popup window with RGB sliders.
Another important thing: If you look at a RC remote for a car, the steering wheel centers itself with a built in spring. This way the car will drive straight if you let go of the wheel. The same applies to the sticks of an airplane remote. For this purpose I made a second window that lets you select which slider or which axis of a joysticks should jump back to the middle position.
Saving those UI layouts is also implemented. This means you can create up to 8 layouts and save or load them. The most recent layout will be loaded automatically with the app’s startup.
Finally, with a press of the back-button on your Android device the editor buttons vanish and you can use the controls you created.
This means that the slider values and button states are transmitted over Bluetooth. Actually I wanted to write the Bluetooth part myself but had to give up after a while. The process of selecting the Arduino from a menu is complicated enough. To save development time I am using the Ketai Bluetooth library again (https://code.google.com/p/ketai/).
The protocol is basically the same as in my previous app, with some additions to support switch states and the slider centering. If a UI element changes, its key (a character A-Z) will be transmitted, followed by its value. This way, the Arduino knows what variable to write the value to. If no control is touched, nothing will be sent. If multiple elements are being changed at the same time, all their values are being transmitted, one at a time. This works fine for up to 3-4 touch points, but you can cause some errors if your try to touch too many elements at the same time, which is should be impractical anyway.
Unfortunately I don’t have a Google Developer account, so you won’t find my app on the Play Store. You can download the .apk-file from this link:
1. Download the .apk and transfer it to your android device
2. Open it with a file explorer and install it
3. Done! You can now create your own Bluetooth Arduino remote
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Example Arduino Sketch
I also wrote a simple example sketch you can upload to an Arduino board of your choice. It handles the serial communication with a Bluetooth board and writes the values of the remote to variables.
This is not a fully features library, so you will have to make some manual adjustments depending on which UI elements are used in the Android app. But this is nothing more than Copy and Paste.
I put a lot of time into it, but the app still isn’t flawless. There is a settings-button, which currently has no function because there are no changeable settings. The Bluetooth protocol could use some reworking, too. But overall I am very pleased with the outcome of this project.