topamax once a day

Android + IOIO + Servo Control

A simple dual servo controller for Android.  The IOIO based device uses slider bars to control two hobby servos.

For additional background information on interfacing Android with IOIO, check out my other introductory tutorials:

Android + IOIO + Simple Digital Output
Android + IOIO + Simple Digital Input
Android + IOIO + Simple Analog Output
Android + IOIO + Simple Analog Input

Background on Android development, IOIO, and electronics:

IOIO for Android Beginners Guide
Android Developer’s Guide



Parts needed:

  • Android Device (1.6+, 2.1 for Bluetooth)
  • IOIO (available at Sparkfun)
  • 2x Hobby servos
  • 2x 10k ohm resistors
  • Breadboard
  • Power supply
  • Hook-up wire



Connect the red, power lines of the servos to +5v, the black ground lines to GND, and the yellow signal lines to the desired output pins, 3 and 6 in the example.  Other pins can be used as long as they support peripheral output (for PWM, marked with the letter ‘p’ on the back of the IOIO) AND are 5V tolerant (marked with a black circle around the pin). This leaves pins 3-7, and 10-14 as the only potentials.  Also, connect the same signal lines to +5V, with a 10k ohm resistor in series.  This allows use of the pins in 5V open drain mode, required since the IOIO operates with 3.3V.  Here is a diagram of the completed circuit (created with Fritzing):



Get the source

With the circuit assembled, the next step is to get the demo application on the Android device. You can either download the pre-built .apk or checkout the source from Github:

git clone git://

If you are building from source, you will also need to import the IOIO Library project, and optionally the IOIO Bluetooth library projects, both available here:

git clone git://


Install, connect, profit!

Finally, upload the app to the Android device (or browse to this page on the device and download the apk above). Connect the device to the IOIO, and start up the app.


  • lin

    i couldn’t slide using the seekbar in sync with the servo help pls!

    • civicexa

      I have the same problem,..:(

      • Looks like there was a problem in my code. The circuit was wired for open drain mode, but was not enabled in the code. In

        panPwmOutput = ioio_.openPwmOutput(PAN_PIN, PWM_FREQ);
        tiltPwmOutput = ioio_.openPwmOutput(TILT_PIN, PWM_FREQ);

        needed to be:

        panPwmOutput = ioio_.openPwmOutput(new DigitalOutput.Spec(PAN_PIN, Mode.OPEN_DRAIN), PWM_FREQ);
        tiltPwmOutput = ioio_.openPwmOutput(new DigitalOutput.Spec(TILT_PIN, Mode.OPEN_DRAIN), PWM_FREQ);

        I have updated the code in the Github repo to reflect the necessary changes.

        • Nick

          Hi Michael,
          I love everything You’ve posted! I have a question – is the pre-built .apk fixed from this problem, and if it is, why do I experience it on my galaxy 3?
          Thank You!

        • slash

          i still got the problem in this line
          here the log

          Description Resource Path Location Type
          The method openPwmOutput(DigitalOutput.Spec, int) in the type IOIO is not applicable for the arguments (Spec, int) /IOIOServoControl/src/net/mitchtech/ioio line 36 Java Problem

          Description Resource Path Location Type
          The method openPwmOutput(DigitalOutput.Spec, int) in the type IOIO is not applicable for the arguments (Spec, int) /IOIOServoControl/src/net/mitchtech/ioio line 37 Java Problem

  • Neil Gibbons

    Really nice tutorial. As a beginner I’m sorry to bother you with such an obvious question but I was wondering how one could modify the above example to control a dc motor (I think that is what you need for controlling remote controlled cars etc.).

    Loving the website,


    • Hi Neil, the code might not actually need to be modified… you can vary the duty cycle of PWM signals to control the speed of DC motors too! However, it is recommended not to directly connect the IOIO to motors, but to use a motor driver breakout board in between. Here is example using a: TB6612FNG Dual Motor Driver

  • charlie

    Can you explain further why the single outputs need to operate in ‘5v open drain mode’?

  • ryan

    what should i do..
    its deprecated and it doesn’t recognize AbstractIOIOActivity

  • Jason

    I second the depreciation of the AbstracIOIOActivity as it causes the app to now force close when I try to build via Eclipse.

  • I seem to have problems related to ioio library linking.

    DigitalOutput cannot be resolved to a type
    Mode cannot be resolved to a variable
    Java Problem

    On project import > I re-linked ioioLib as ioioLibAndroid because ioioLib is no longer listed that way. Should that work?

    also: I copied the github project to my workspace manually and impored with “copy to workspace” UN-checked to avoid directory structure corruption in ioioLibAndroid.

    Am I off base, or no where near the ballpark?


  • Hey there! Thanks a ton for the tutorial 🙂

    tI’d just like to ask, looks like you used a dongle to connect to the IOIO wirelessly. What dongle did you use? Bluetooth?

    Did it require anything special to setup?

  • donjon

    Is the apk built for Android or Google API? And what level?

  • how can we turn right or left a servo as simple?

  • Ailton

    Where i can buy