In this Tutorial I want to show you how to control your Arduino project with an Android phone or tablet.
You can already find a lot of solutions for this on the Internet but most of them don't offer the features that are needed for a more complex project. For this reason I created my own android app which lets you create your own remote controller with a customizable layout. Its features include 10 finger multitouch, an easy to use interface, 8 save slots for controller layouts and much more.
The app is not on the Google Play Store (yet).
You can install it just as quickly via the .apk-file.
(Transfer the file to your phone and open it with a file explorer)
There are basically two modes: the editor mode, where you can edit the layout and control mode, where you can only see the remote you created and the app sends data over bluetooth. The back button toggles between the these two.
The right side of the editor shows buttons for loading and saving the layout. On the bottom bar are controls for creating new UI elements, and changing their settings.
The four basic UI elements are the switch, joystick, button and checkbox. You can create them by dragging the corresponding buttons to the center. Size and position can be changed by moving its center or corner.
Step 1: Wiring
In this simple example we will control a few leds via bluetooth
- Bluetooth Module (e.g. HC-05)
- 3 LEDs and resistors
- prototyping board
Connect the RX and TX pin of the bluetooth module to pin 10 and 11 on the arduino.
Connect the leds to digital pins 3, 5 and 6. If you are not using a Nano make just sure you connect them to PWM outputs.
Plug in Vcc and Ground, dont forget the resistors for the leds.
Step 2: Programming the Arduino
For this example you can download the sketch from the instructables page.
The Arduino simply listens for a character from the bluetooth module and then assigns the following value to a variable.
If you want to program the Arduino for your own project you can start with this:
This lets you output all received values to the serial monitor.
Step 3: Creating the Remote
On startup the app will ask you to turn on bluetooth and connect to a device.
If you don't want to connect yet, just press no and cancel.
you should be in the editor window now (if not, press the back button)
Drag a slider, joystick and button to the screen.
Select each of them and assign a key using the A-button.
A for the slider, B for the joystick and C for the button.
Step 4: Using the Remote
That's it. You can press the back button now (or the play-triangle).
The editor controls will vanish and you can now control your Arduino with your Android device.
Step 5: Advanced Options
I wanted to keep the example short, but there are a few more things in the app that I want to show you:
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 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.
You can customize the colors of UI elements and the background using an RGB-slider.