Arduino ADK LED Lighting

70K22121

Intro: Arduino ADK LED Lighting

Have you ever wanted to control electronics with your smartphone?  The Arduino ADK (Android Development Kit) is the Arduino Mega with a built in USB host device, ready for your smartphone to be plugged in!  We'll make a simple introductory project with a few LED strips and a relay (to control the high voltages of the LED strip).  For this project, you will need no Android programming experience (or even learn how to code Android!), but a moderate Arduino code understanding.  We'll use the easy Handbag app for Android.

This Instructable will cover how the Arduino ADK works, how to use it with Android devices, and how to make a cool example project of lighting up LED strips with Android!!!

Please vote for me in the Make to Learn Youth Contest and Lamps and Lighting Contest!!!  Every vote counts!



What did you make?

I made a tutorial on the Arduino ADK, which I found little documentation on in the past.  I wanted other people to learn all about the Arduino ADK easily, once they got one and didn't know how to use it.  The 'ADK in-depth' part of this Instructable is a compilation of many resources that I have found on the internet.  I also created an 'example project' in Step 4-8 to interface an LED strip (with a relay, which I have never worked with in the past) with the Arduino ADK, and an Android device.  The simple program uses the Handbag application and libraries (wasn't designed by me) to make a simple application menu for the Android to turn on/off the LED strip.

How did you make it?

I used many of my prior electronics and soldering skills, and some electronic components I have gotten in the past.  My parents gave me the LED strip last Christmas, and I got the Arduino ADK at Maker Faire Bay Area 2012, but didn't know what to do with it.  Later on, I looked online and found the Handbag application, and started coding in minutes.  Using only Arduino programming (which is the great part of Handbag, you don't have to write any Android code), I coded a simple application menu that activated the relay that switches the LED strips on and off.

Where did you make it?

I made the project mainly in my garage/hackerspace (Qtechknow Labs), where I teach many of my friends DIY electronics.  I also used my soldering iron and project desk.  I have gotten many of my soldering skills at booths at Maker Faire, and lots of my electronics skills around the internet!  I looked at Arduino.cc as well as Google Developers to get to know what the Arduino ADK was about, even though I didn't understand it at first.

What did you learn?

I learned all about the Arduino ADK, relays, and Android devices, all of which I had no experience with in the past.  I learned that everything fails at first, but you have to keep on trying to get it the way you want it.  I'm super excited that I now know all about the Arduino ADK, so I can design some more cool Android projects!

STEP 1: Parts and Tools

The total cost of the parts is about $28.50, excluding the Arduino ADK and LED Strip.

Parts:

Arduino Mega ADK (Makershed, $85)
USB-B Cable for Arduino ADK Programming (SparkFun, $4)
LED Strip - 1M (you only need 2 feet; Adafruit, $20)
2N2222 Transistor (Digikey, $0.34)
Relay SPDT (SparkFun, $2)
Diode Small Signal 1N4148 (SparkFun, $0.15)
10K Resistor - 1/6W (SparkFun, $0.25)
Half Size Breadboard (SparkFun, $6)
12V DC Power Adapter (SparkFun, $6)
Jumper Wires (SparkFun, $4.50)


Tools:

Android Phone (Check OS requirements)
USB cable for Android Phone
Soldering Iron
Solder
Wire Strippers
Safety Glasses
Safety Mask or Solder Fume Extractor
Laptop
Wire (only a little bit is needed)

STEP 2: Introduction to the Arduino ADK

The Arduino ADK is basically an Arduino Mega with a built in USB host controller.  It has over 50 digital pins, 15 analog pins, and many more for communication.  It has a very fast processor with over 200kb of memory to store code!!!  In most programs, you use less than 15kb.

The Arduino ADK can communicate with Android devices, or basically any USB slave (i.e. keyboard, mouse).  It has a MAX3421E that communicates with the ATmega2560 through SPI to transmit and receive data to the Arduino ADK.

Some of these concepts might be a little confusing, but you don't have to understand them in full detail to make a simple Android app.

STEP 3: Handbag for Android

Just a few days ago, I stumbled upon this amazing app for Android called Handbag.  With this app, you don't even have to write any android code, you only have to write Arduino code!!!  It's quite possibly the easiest way to interface the Arduino ADK with your Android device.  You can use the simple Handbag classes/libraries for Arduino ADK to program both the phone interface and the Arduino ADK IO pins (sensor and output pins).

Go here to download the program for your Android device, since it isn't on Google Play.  Click on the .apk package, and it should download and run.

To enable developer options, go into Settings>Developers>Enable USB Debugging and click OK, so that the Handbag app will run properly on your Android phone.

STEP 4: Arduino ADK Project

Last year for Christmas, my parents gave me two LED strips, each white and ~2ft long.  At first, I didn't know what to do with the LED strips, because they are basically just multiple LEDs in a line, but when I kept on straining my eyes to see some of my tiny electrical components, I figured I needed a new light.

First, I hand crafted some balsa wood to make a base for the LED strip to stick to.  Then, I soldered the GND to GND and the +12V to +12V on each of the LED strips, so that when you applied power to one, the other one would light up also.  This part of the step doesn't require any programming.  I soldered a yellow wire (I didn't have any red) to the + side of the LED strip, and a black wire to the - side so I could remember which pins they were later on.  Next I soldered a switch in series to the positive side of the LED strip (not at all needed).  The two wires that were left were my + and - from the LED strip.

STEP 5: The Circuit

Next, we'll move on to making the relay circuit.  You can see how to assemble the circuit using the Fritzing diagram above.   Here are the pin assignments from the breadboard to the Arduino ADK or LED strip:

  1. Left pin (from Fritzing view) of transistor goes to GND of the Arduino ADK
  2. Other end of 10K resistor goes to D7 on the Arduino ADK
  3. The rightmost pin (on the top of the breadboard) goes to the + side of the LED strip
  4. The rightmost pin (on the bottom of the breadboard) goes to the + (or red) of the JST to Barrel Jack Connector
  5. The GND of the LED strip goes directly to the - (or black) side of the JST to Barrel Jack Connector

Note:  You should only be connecting wires to the JST to Barrel Jack connector, not the power supply.  Also, don't plug in your JST to Barrel Jack to the power supply, or the power supply to the wall.  For safety, we will do this after we are sure that we don't have a short in our circuit.

Make sure that your circuit looks exactly like the one above.

STEP 6: Coding

Below is both of the Arduino libraries that you will need to install to run the programs correctly on your Arduino ADK, as well as the actual Arduino code.  First, unzip them using an extraction tool (built-in for the Mac and Windows).  To install the libraries, go to your Documents folder, then into the Arduino folder, and then drag and drop both libraries into the libraries folder.  If you don't happen to have a libraries folder, don't worry.  You can make one yourself!  While in the Arduino folder, make a new folder, and name it "libraries" without the quotations.

Once you are finished, go ahead and close the Arduino program, and then go back into it.  The only reason we did this is because every time that you install a new library, you have to restart the Arduino program.

Unzip the ledStripADK folder, double click the ledStripADK.ino file, and it should open the Arduino IDE (Integrated Development Environment, the main program to code Arduino) with the code.  I strongly encourage you check out the code and the comments in the code that I made, to understand it better.

Basically, the code makes an app menu using the Handbag library, initiates the relay control pin, and when the user presses a virtual button on the Android device, the relay should turn on or off, depending on which button you pressed.

STEP 7: Final Touches!

Now, plug the USB into your Arduino ADK (if you haven't done so yet), and plug the 12V DC Power Adapter into the wall.  Then, plug the barrel jack of the power adapter into the mating barrel jack on the JST connector together.  Plug in your Android phone, and load up the Handbag app.  Plug in your USB cable for your Android into the Arduino ADK, and plug the other side into your Android device.  If you soldered in a switch with your LED switch, turn it on, so that current flows.

The app that I designed should come up, and when you press the "Turn LED Strip On" button, you should hear a click (which is the switch in the relay), and the LED strip will light up.  When you press the "Turn LED Strip Off" button, you should hear another click (which is the same switch in the relay, just going the other direction), and the LED Strip should go off.  However, if you press the "Turn LED Strip Off" button while the LED strip is off, the relay won't click, or the LED won't go off, because it is already in that state.

STEP 8: Finished!

Yay!!!!  You have finished your Arduino ADK LED Lighting project, as well as learned a bunch of electronics, code, and Android!!!

If you like this Instructable, please tell all of your friends!!!  If you know of a person that loves LEDs, would like them installed in their house, wants an easy way to control them, but doesn't know how to do it, you can modify the project to fit your needs!!!

Thanks for reading my Instructable!!!

P.S.  I'm 12 years old  :D

21 Comments

Nice project- no matter what your age. I am teaching an Arduino class & I' ll have them link to this. Never heard of Handbag but will have to give it a try. Thanks.
Qtechknow, great tutorial. I always learn so much from you. Keep it up. Thanks!

How would you make it detect your presence and turn the light on and off based on your proximity?

Just curious.... thanks again!

-mat
Thanks!

I think that you could use a PIR Motion Sensor for sensing your presence.  The PIR motion sensor works by taking a picture every second, and comparing them to see if the picture changed/motion occurred.

You could use a Ping proximity sensor to tell how far away something is, like your hand.

Using the Arduino ADK, the Android could be a digital display for the sensor data, and the Arduino can decide based on the readings for the sensors whether to turn the light on or not.

I've seen a project done like this, called the Luminch One.  It uses only a proximity sensor (basically a ping sensor, but a different brand), and when you wave your hand over the lamp, it fades on, and you can adjust the light by moving your hand up and down.

Hi, I have been having problems with the files, things such as "'UsbHost' was not declared in this scope" and other issues. Could you post a tutorial video on youtube or make these instructions more clear on setting up the code to run on the arduino.

thanks

BTW Im 15 and studying engineering

same with me, hope so you can share tutorial video on youtube

same with me, hope so you can share tutorial video on youtube

What would i put in this section to make the leds blink until turned off?

void turnLedOn() {

digitalWrite(ledStripPin, HIGH); // turn LED strip on when button is pressed

}

void turnLedOff() {

digitalWrite(ledStripPin, LOW);

}

Awesome I like it very much. Your instructables are so great I'm as old as you, but I'm just a begimner and you're an expert. It looks like you're able to build and make everything

我可以有Handbag.apk的代碼?


我可以有Handbag.apk的代碼?


it good to have young kids inerested in electronics
ps im 11
I am glad to hear that you are working with ADK and Handbag . I bought an Electric Sheep board , but I have not done anything with it yet.
Great work Q!
Build_it_Bob
Thanks for all of your comments! I believe that the handbag app is compatible with the electric sheep. :D
Great project.
Can i use another Arduino set, say Uno, beside Mega?
Thanks! You can use the USB host shield from SparkFun with the Uno to have the Arduino work as the USB host, however I have not tested this with Android devices.
If I ever get an Arduino ADK I will definetly use this instructable.
Nice i'ble!
I gave ya votes on all of the contests!

Good luck!
Thanks for the votes!

Love your Lockduino Instructable, too!
More Comments