topamax once a day

Android + IOIO + Simple Analog Input

Simplest possible analog input with Android and IOIO. This article will discuss the bare minimal requirements for development of an Android USB (or Bluetooth) analog input device.

The goal is to demonstrate the easiest possible use of the technology. For additional background information on Android development, IOIO, and electronics, check out these links:

Meet IOIO
IOIO for Android Beginners Guide
IOIO Wiki
Android Developer’s Guide

 

Hardware

Parts needed:

  • Android Device (1.6+, 2.1 for Bluetooth)
  • IOIO (available at Sparkfun)
  • Rotary potentiometer
  • Breadboard
  • Power supply
  • Hook-up wire

 

Assembly

Connect one side of the potentiometer to +3.3V, the opposite side to GND, and the center wiper to the desired analog input pin on the IOIO. The example uses pin 34, but can be used with other pins that support analog input (pins 31 – 46 on the IOIO). Here is a diagram of the completed circuit (created with Fritzing):

 

Software

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://github.com/mitchtech/android_ioio_simple_analog_input.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://github.com/ytai/ioio.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.

 

  • Pingback: Android + IOIO + Laser Turret | MitchTech()

  • Pingback: Android + IOIO + Laser Tripwire | MitchTech()

  • Pingback: Android + IOIO + Countdown Timer | MitchTech()

  • Amiram

    what is the max ohm value of the Rotary potentiometer

    • With this potentiometer, the values range from 0-1024

  • Amiram

    why the value on the screen flickers, even when not connected

    • This is because the pin is not configured with pull-up or pull-down resistors. The GPIO pins can be pulled up or down externally (ie physically connected) or internally (ie enabled with software). Since neither type is being used, the output is subject to random electrical noise and appears to ‘float’ randomly.

  • Pingback: Android + IOIO + D-Pad | MitchTech()

  • John Jorsett

    The source code that I downloaded and built from GitHub uses pin 40, not 34 for the analog input. No big deal, I just moved the wire, but you might want to fix either the source or your writeup on this page. Thanks very much for putting this example together, and for anyone else trying it, pretty much any value of potentiometer should work. The one I’m using is 100K ohms.

  • Keisha

    Hi, is this supposed to work with Android 4.4 devices? I ask because I was trying to do this example and apparently the app is not receiving the data but I measured the voltage in the potentiometer and it is indeed changing as I adjust the resistance. Thanks!

  • rk android

    how can i get battery percentages in my mobile phone i’m trying by using getVoltage() method but it return 66 % when battery is down. so can you help me how can i get.
    I just want to display battery percentages in my phone in text mode.