Instructables

or watch in HD

The Android phone is controlling an LED strip hidden in the vase using a IOIO board with Bluetooth. In this example, the Android phone is running an app which obtains color values from the onboard camera and then in turn matches those colors to the LED strip. We (myself and Ytai) sort of ran out of time on this project but with the sample code, it can easily be expanded to do other things. Here's a few ideas we didn't get to:

    Using the phone accelerometer to change the color patterns, a shake event for example
    Displaying a pattern when receiving a text
    Displaying a pattern when receiving a phone call   
    Displaying a pattern when a friend if nearby via social networking
    Displaying a pattern on specific Twitter keywords

IOIO is a physical computing platform for the Android platform, kind of like Arduino but dedicated to Android and features a small form factor with Bluetooth capability leveraging off the shelf & inexpensive Bluetooth dongles. IOIO was created by Ytai Ben-Tsvi who was my partner on this project, actually Ytai did all the work. I've done a few Arduino projects in the past that also required a PC for the graphical & rich internet application capabilities, it was nice see how one can get rid of the PC and yet still retain these rich capabilities leveraging the Android platform. This opens up many new application possibilities for hobbyists.

The LED strip is digitally addressable meaning each LED (32 in the strip) can be controlled individually. That combined with the Bluetooth IOIO and Android opens up endless interactive lighting schemes.

Materials

* Android 2.3.3 and above required for Bluetooth
Android 2.1 to 2.3.2 will support Bluetooth but you'll need to enter the Bluetooth pairing pin on every connection
Android 1.5 and above can use a USB cable connection as opposed to Bluetooth. For USB connections, the "USB debugging" setting (also known as ADB) must be turned on in your Android phone, you'll find this setting under "Settings", "Applications", and "Development".


 
Remove these adsRemove these ads by Signing Up

Step 1: Wiring

The wiring is pretty easy. First and this is very important, look for the connector on the LED strip with an arrow (see the pictures), it should be the strip end with one connector as opposed to the strip end with two connectors. That is the end of the LED strip where you'll connect the 4 wires per the schematic below. The other end of the LED strip (with two connectors) also has a similar connector but you'd use that to daisy chain another LED strip. In this particular case, we're only using one LED strip so we don't need this connector. If this is the case for you, then you can save yourself some time by cutting off that connector (female) and then plugging it into the single connector end (male) and then wire to the IOIO board.

Outside of the DC power source which go to the VIN and GND pins on the IOIO (DC power between 5V and 15V), you'll only need to connect 4 wires on the LED strip to the IOIO.

LED Strip Blue Wire -->    IOIO 5V
LED Strip Black Wire -->  IOIO GND
LED Strip Green Wire --> IOIO Pin 3
LED Strip Red Wire -->    IOIO Pin 4

Step 2: Quick Test Before Installation

Do a quick test to ensure the LED strip can be controlled by the Android device. Connect the bluetooth dongle to the IOIO, power on, and then pair to your Android device. It will show up as "IOIO (address number)" in the bluetooth discovery screen. Select it and then enter "4545" for the pairing code.

Then install the Holidays IOIO app for this project and see if the LED strip lights up. Make sure the camera on your phone is not facing down so it's picking up some colors.

Step 3: Installation

With the electronics working, now it's time to install the LED strip in your form factor of choice and also hide the IOIO board somewhere in there. If it's a permanent installation, then you'll want to solder the wires from the LED strip directly to the IOIO board or if it's temporary, then solder some header pins on your IOIO board and connect to the LED strip using jumper cables.

The LED strip has an adhesive backing so you can just stick it on.

Step 4: The Fun Part

Picture of The Fun Part
Now the fun part. Here's where you'll write the code to tell the Android phone how to control the LED strip. To make things easier, refer to the example code of this project and then just tweak for your needs, here's a direct link to the Android activity code (main body of code). The sky is the limit here in terms of interactive scenarios, anything you can get to with an Android phone becomes possible.

For the folks that know Arduino, coding Android is a little more difficult but not too bad, you'll get the hang of it pretty quick. Here's the traditional "hello world" application for IOIO and Android. Read through the code along with the comments in Bold Italics and you'll get the gist.

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.
        */
 
       @Override
       public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState); //all Android app have this line, just make sure it's there and don't worry about it
              setContentView(R.layout.main);    //in Android, the screen layout comes from an XML file you specificy, main.xml here
              button_ = (ToggleButton) findViewById(R.id.button);
       }
 
       /**
        * 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()
               */
 
              @Override
              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()
               */
 
              @Override
              protected void loop() throws ConnectionLostException {
                     led_.write(!button_.isChecked());
                     try {
                           sleep(100);
                     } catch (InterruptedException e) {
                     }
              }
       }
 
       /**
        * A method to create our IOIO thread.
        *
        * @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
        */
 
       @Override
       protected AbstractIOIOActivity.IOIOThread createIOIOThread() {
              return new IOIOThread();
       }
}

 

kkrumwiede12 months ago
Has anyone had problems with these LED strips? I just received my second strip from Sparkfun thinking the first was bad but I'm finding the second one has the same behavior. I'm quite familiar with the IOIO... and followed this instructable... I also tried plugging in the LED's to an arduino and found the same behavior. The last (or maybe the 1st) LED (the one furthest away from the IOIO connection is the only one that lights, and it seems to cycle through the colors on that single LED only if I touch the end of the opposite connector. When the first strip began behaving this way, I thought there might be a bad connection or one of the chips was bad, so I cut and rewired a portion of it... and had the same behavior... so it is starting to seem like an issue with power or cycling through the LED's. Should all the LED's turn on as I connect to 5V supply and ground? If not, is there another simple way to check all the LED's in the strip before I get into the programming (although knowing Ytai, I trust the code Holiday IOIO app works fine)... I am trying to build this into something this week before the Greenbrae mini-maker Faire next weekend so any help would be GREATLY appreciated!
vov352 years ago
hmm... you're running LED strips directly off microcontroller pins? wouldn't it be best to isolate them with transistors?

Regardless, nicely done, I quite like the effect.
power_tr vov352 years ago
Not like that!
Each LED has its own WS2801 IC and current limiting resistors.
hi can you provide me detail for some discussion

email: subrotradeindia@gmail.com
alinke (author)  subrotradeindia2 years ago
Hi, all the tech info I have is documented in the instructable, is there any particular area you want more info on
ytai2 years ago
@vov35 the IOIO pins aren't driving the LEDs, only controlling them. The LED strip itself has the drivers.
Only two I/O pins on the IOIO were used: clock and data, both fed from an SPI module.