INTRODUCTIONThis is the beginner's guide for using the MIOIO card, and is intended for users who have never written an Android application. The purpose of this tutorial is to show you how to write a simple application that communicates with the MIOIO card.


The programming language used to write an application for Android is Java. If you're not familiar with Java, this tutorial only reviews a simple Java application using the MIOIO library. This tutorial does not cover how writing Java code will also cover how to use the advanced features on your Android device, such as GPS, accelerometer, touch screen, etc. Once you get to the point where you want to use the wide range of features of your Android, we suggest you first look at the technical resources section on If you still can not find the examples you are looking for, simply by browsing the internet you will find lots of information and examples that show how to communicate with all the great pieces of hardware in the Andriod device.

Overall, the holy grail for Android application development is . There you will find most of the information on Android development.

Here are the pieces of hardware you will need to complete this tutorial:

Android device enabled with OS 1.5 or higher
MIOIO card, with compatible adapter or bluetooth cable.
USB cable that is compatible with your Android device
A power supply of between 4.5 - 6V with at least 1A of the current.

INSTALLING THE DEVELOPMENT ENVIRONMENTThe first thing you need to do is download the Eclipse development environment from here.

You should also download and install the 32-bit JDK6, which you can download from here and for 64bits from here.When you have the JDK6 installed, you can start the ECLIPSE.

Now, we have to prepare the Eclipse to serve as a development environment for Android.

Step 1:

Iniit Eclipse.

Step 2:

Go to menú Help -> Install new software.

In the box work with, put next link:



Select the Developers Tools box, and continue.



Click Next.



Accept the conditions and finish. The necessary software will be installed to use the Android SDK in Eclipse.



You may get a sign like this, ignored and continue with the installation.



You will be asked to restart the Eclipse.



Step 3:

Restart Eclipse.

Step 4:

It should have appeared in the menu above icons like these:iconos.jpg

Click on the icon that has the down arrow is the SDK ANDROID MANAGER. It will open a window in which you will have to download the SDK necessary to program in the version you want android.



Select the version in which you want to program your application and install the packages, I recommend that you use at least 2.3.3. onwards. (Especially for Bluetooth compatibility).

Step 5:

Import  Example HelloIOIO

Instead of creating a new project from scratch, we can import an existing IOIO project that has all the files ready to go. If you need instructions on how to create a new project, see the Hello World example at


1 ) Dowload Software image' archivo zip MIOIO.

2) Unzip the downloaded package in a safe place where you want to save the project files.

3 ) Then, with Eclipse open, in the menu Go to File> Import and select Existing Projects in Workspaces. Then click Next.



4) A window will open, (as shown below). Select 'Select root directory' and navigate to the file you just extracted and select the folder HelloIOIO located in / Applications / HelloIOIO Make sure the check box for your project now ends up accepting.



5) You should now have HelloIOIO in the project explorer in Eclipse. Note that there is a small red x next to the project name. This means there are compilation errors, so every time you see this, you will know that something needs to be fixed. In this situation, it is necessary to link the MIOIO library to our project, as indicated in the next step.




6) Now we have to link the library and the IOIO Bluetooth IOIO library to your project that will give you full access to the IOIO API. The IOIOLib and IOIOLibBT directories contain the libraries that allow you to communicate to the MIOIO.

Follow the same exact steps in 3 and 4 except using the IOIOLib file and then the IOIOLibBT instead of the HelloIOIO file.

After you add the library files to the workspace, select the HelloIOIO project, then on the top toolbar Go to: Project> Properties. Then select 'Android' from the list on the left. In the "Library" section, click Add, and then add both the IOIOLib and IOIOLibBT libraries. You should see both of them with a green mark as shown below (note: the image does not show the IOIOLibBT but should be there if using Bluetooth).


Also, make sure that the 'Project Build Target' is correctly selected according to the specific Android operating system you are using.

Note: If you ever have to change your target generation (if you are using a device with a different Android operating system), you can change it here.
7) The next thing to do is make sure your application has Internet permissions. To do this, open the AndroidManifest.xml file located in the main project tree. Make sure it is on the Permissions tab, click Add> Usage Permissions, then make sure the 'Name' field is android.permission.INTERNET. See the image below as reference:



After you have done this and saved the project, the project explorer window should look something like this:



Notice the red x error indicators are gone.

In case the error indicators x continue to appear, try unchecking the Build Automatically option in the Project menu. Select the Hello_ioio project in the file tree and in the same Project menu, press Clean to clean the project.


The project tree has many files. You really do not have to mess with the IOIOLib project tree so you can minimize that. The file containing the java code for the IOIO is in HelloIOIO> scr> ioio.examples.hello> Double-click the file and you should see this:



Here you can start writing code and change the HelloIOIO program. At this point you can continue reading or jump immediately to the compilation of the IOIO program and test the application.

The file contains the code that communicates with the MIOIO. If you want to change the user interface (user interface or graphics) of your application, the file resolution> layout> main.xml is where the changes are made. The main.xml file in the HelloIOIO example uses an interface that looks like this:


For more information on XML layouts, see the Hello World example at, then scroll down to the "Update UI for XML Layout 'section.

At this point, you should be ready to write your own Android IOIO application. Now you can continue reading or jump immediately to the compilation of the IOIO program and test the application.

Project Errors
Eclipse has the ability to compile the code in real time. When an error occurs, a red x will appear somewhere in your project. This can mean many things. To find out what the errors are, Eclipse has tab called "problems" that shows what errors it is getting. This tab is usually toward the bottom of the Eclipse window. Sometimes, the error will tell you exactly what is wrong and sometimes the mistakes are more obscure.

If there are unknown errors in your project, please consult the IOIO - OTG troubleshooting guide.

Example IOIO
Once the HelloIOIO file is imported and linked to the IOIOLib file, you are ready to start writing code. The example shows an activation button on the screen, allowing the LED board to be controlled. This example shows a simple use of IOIO and will give you an idea of ​​what to expect when programming.

The code in the file is shown below.

        package ioio.examples.hello;

import ioio.examples.hello.R;
import ioio.lib.api.DigitalOutput;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.AbstractIOIOActivity;
import android.os.Bundle;
import android.widget.ToggleButton;

* This is the main activity of the HelloIOIO example application.
* It displays a toggle button on the screen, which enables control of the
* on-board LED. This example shows a very simple usage of the IOIO, by using
* the {@link AbstractIOIOActivity} class. For a more advanced use case, see the
* HelloIOIOPower example.
public class MainActivity extends AbstractIOIOActivity {
private ToggleButton button_;

* Called when the activity is first created. Here we normally initialize
* our GUI.
public void onCreate(Bundle savedInstanceState) {
button_ = (ToggleButton) findViewById(;

* This is the thread on which all the IOIO activity happens. It will be run
* every time the application is resumed and aborted when it is paused. The
* method setup() will be called right after a connection with the IOIO has
* been established (which might happen several times!). Then, loop() will
* be called repetitively until the IOIO gets disconnected.
class IOIOThread extends AbstractIOIOActivity.IOIOThread {
/** The on-board LED. */
private DigitalOutput led_;

* Called every time a connection with IOIO has been established.
* Typically used to open pins.
* @throws ConnectionLostException
*             When IOIO connection is lost.
* @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
protected void setup() throws ConnectionLostException {
led_ = ioio_.openDigitalOutput(0, true);

* Called repetitively while the IOIO is connected.
* @throws ConnectionLostException
*             When IOIO connection is lost.
* @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
protected void loop() throws ConnectionLostException {
try {
} catch (InterruptedException e) {

* A method to create our IOIO thread.
* @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
protected AbstractIOIOActivity.IOIOThread createIOIOThread() {
return new IOIOThread();

In the code above, there are lots of comments that explain what each line does. This application is a great starting point to make sure your development environment and MIOIO board works properly.

Eclipse is a very powerful tool and gives debug information in real time. For example, if you write the code that does not make sense, Eclipse will display a red x next to the line in question, and will even give you suggestions on how to change the line of code. Simply place your mouse cursor over the line and you will see something like this:

Note that if you have errors, you will not be able to compile and execute the code, you will have to correct the errors.

Also, the IOIOLib has exhaustive JavaDocs that can be generated and scanned from within Eclipse. Go to Project> Generate Javadocs.

Here are some more resources to help get you out of code writing:

For all types of Android, see the Android Package Index.
For IOIO types and examples, see the IOIO - OTG Wiki.
Compile, load and run the app on your Android device
If you change any part of the code, simply saving the project compiles the program and creating a new HelloIOIO.apk file. An apk file is a compressed Android package file, similar to zip and jar. Files, which is used to create an application on your Android device. This file can be found in the HelloIOIO project tree in the bin directory.

Here are the steps to get the sample application working on a N1 Android phone running the 2.3.3 platform.

1 . Enable USB debugging. Settings> Applications> Development> USB debugging Enable

2 . Install the apk file. The easiest way to get the apk file on the device is to connect the device to your computer. When you are prompted to install the drivers, select the driver that is on Android (it must be in Program Files for Windows Users)> android -sdk> extras> google> USB_Driver. Then right click on the HelloIOIO project in the project explorer in Eclipse Go Run As> Android Application (or hit the green button I tap on the top toolbar the application runs too). Your apk file should now be installed on your Android device. Disconnect your Android device from your computer, then move on to the next step. More information about the USB USB driver is here.

3 . Prepare the MIOIO board. The only thing you have to do for the HelloIOIO example is to feed the IOIO board. Keep in mind, the IOIO board will always need an external power supply between 4.5 -6V. Single cell phone batteries do not work, you need an input of 4.5 -6V. You can connect the power supply to the VIN and GND terminals (they will have to be welded in place the connectors).

4. With the MIOIO powered, you can connect the USB cable to the MIOIO and to your Android device. The Android device should show that USB debugging is connected in the notification bar, in addition, the Android should indicate that it is loading.

5 . Open the Hello IOIO application and press the button, you should see how ed status LED turns on and off. !! Congratulations!! You are now on the way to creating your own applications for MIOIO!

Note: The best way to develop applications for MIOIO is to have the phone connected to your computer while you are writing and editing the code. After running the application (as shown in step 2), you will delete the old application and load the application you just edited into the phone. Now you can disconnect the phone from the computer, then connect it to the MIOIO to test what you have done.

Leave a Reply

Your email address will not be published.