Multi color Lamp using Amarino, Android and Arduino ‹ BUILD CIRCUIT

Multi color Lamp using Amarino, Android and Arduino





This tutorial is for novices who have never made any Android application or worked with amarino. I strongly recommend you to work with SensorGraph before you start doing this project. For doing SensorGraph project, please click on the following link: How to Make SensorGraph


We need following components/equipments for this experiment:

a. Android Smart Phone- I am using ZTE Blade. See the operating system specifications on the given link. Quite cheap and good looking.

b. Arduino Duemilanova ATmega 328

c. Eclipse IDE for Java EE Developers

d. Androidsdk

e. Amarino Toolkit

f. Bluetooth Modem – Bluesmirf Gold

g. Three LEDs- Colors: RED, BLUE and GREEN. OR one RGB LED.


Step 1 Install Amarino

Go to http://www.amarino-toolkit.net/ and download the following applications on your mobile phone

a. Amarino – Android Application- to be installed on phone.

b. Amarino Plug-in Bundle- to be installed on phone.

c. Amarino Library- To be kept in computer- needed while installing the application on phone using Eclipse.


Step 2 Download Meet Arduino Library

Download the MeetAndroid Library and place it into the libraries Folder Arduino.

After placing the folder into the libraries folder, you should be able to access all the amarino files through the arduino programming environment.

You can see the picture below(Click on the image to enlarge it):


Step 3 Set up Bluesmirf gold adapter

Connect the blue smirf gold Bluetooth adapter in the following way:

CST–1 to RTS–0
VCC — 3.3V
GND — GND
TX — RX (digital pin 0 of arduino)
RX — TX (digital pin 1 of arduino)
NOTE: Your Bluesmirf Bluetooth Module should have 57600 baud rate. Otherwise, it won’t work. Here’s a tutorial for checking the actual baud rate of your module and changing it if it has something else than 57600.
HOW TO CHANGE BAUD RATE OF BLUE SMIRF BLUETOOTH MODULE

Step 4 Test the communication between Bluesmirf module and Arduino

Click herehttp://www.amarino-toolkit.net/index.php/getting-started.html

Step 5 Set up Eclipse

It is the most complicated part of this experiment.
You can get a detailed tutorial from http://developer.android.com/sdk/eclipse-adt.html#installing
The basic idea is to install the Eclipse first(follow the system requirements), then install the android SDK, then install ADT plugin for Eclipse IDE. I strongly recommend you to follow the instructions seriously.
What is Eclipse?

Step 6 Download the Multicolor Lamp folder

Download the Multicolor Lamp example from http://www.amarino-toolkit.net/index.php/download.html and place it in a folder(anywhere). DIRECT DOWNLOAD

Step 7 Work with Multcolor Lamp

Go to Eclipse and right click your project panel, and select new android project. In the picture below, you can see that I have selected Android 2.1 because my ZTE phone has Android 2.1 API 7.

NOTE: you need to have Androidsdk plugin installed.

- Select ‘create from existing source’.
- Use the browse button to find your Multicolor Lamp folder that you just downloaded.
- Select android 2.1 OR any other versions as the targeted device from the list. It depends upon the phone you use.
Click Finish.

*You might get yellow exclamation warnings next to your MulticolorLamp project, it doesnot affect your project, so, just ignore it.

*If you have a red “X” you might need to make you have your “AmarinoLibrary_v0_55.jar ” file is included. Download it from http://www.amarino-toolkit.net/index.php/download.html

*To include the file, right click on your Multicolor Lamp folder and click build path > configure build path > libraries > add external jar > and browse for the AmarinoLibrary_v0_55.jar file. > ok


**Very very Important- Open the MultiColorLamp.java file in Eclipse and place your bluesmirf device number inside this line of code ( private static final String DEVICE_ADDRESS = “YOUR BLUE TOOTH DEVICE NUMBER”;)

** Changing AndroidManifest.xml file. Go to Application and set Debuggable as ‘True’.


Phone side (HOW TO INSTALL THE APPLICATION)

Your phone should already be connected via usb to your computer, In your phone settings, developer debug mode, and install from unknown sources checked.

In my phone, it was in settings>applications>USB debugging.

 

Next, right click on your MultiColorLamp folder and > Run as Android Application.

When the dialog box of the AVD manager launches select your phone as the targeted device. It will be the one that does not say emulator and probably have some device number to it.
Launch
This will install the Multicolor Lamp app to your phone and run it.

—————————————-

WARNING: If your application is not installed on phone, then there is a possibility that your phone’s device driver is not installed on computer. Go to Device manager and install the driver for your phone. If you have internet connection, it searches itself for the driver. You can get more information from here: http://developer.android.com/guide/developing/device.html

——————————————-


Arduino Side

You can get arduino code file on one of the folders of MultiColorLamp. Set the baud rate to 57600 and write it to your chip.

While uploading the sketch to arduino, remove the RX and TX connections of bluetooth module.

The Arduino set up is very easy. You just need to connect 3 LEDs across DIG 9- GND, DIG 10- GND and DIG 11-GND. Though I have used ready-made Bluetooth shield, I don’t recommend you to buy that.

If you have never done this kind of experiment before, I recommend you to do this experiment first:http://arduino.cc/en/Tutorial/Fade


-After uploading the sketch and fixing the circuit, connect the bluetooth module. Connection of bluetooth module has been described earlier in this tutorial.

If you follow the instructions carefully, your application will work. Please write me if you have any problem.

You can watch the project in action on the following video:

The application automatically makes connection with the bluesmirf module.


Check your experiment

1. Did you edit the MAC address?

2. Did you set ‘Debuggable’ as True in AndroidManifest.xml ?



3. Did you set the baud rate of Bluesmirf Module to 57600 and set the same baud rate in arduino sketch?

http://www.circuit-blog.com/how-to-change-baud-rate-of-bluetooth-modem-bluesmirf-gold-using-arduino-terminal/

4. Did you connect the bluetooth module in right way?

CST–1 to RTS–0
VCC — 3.3V
GND — GND
TX — RX (digital pin 0 of arduino)
RX — TX (digital pin 1 of arduino)
5. Did you remove bluetooth connection from Arduino board while uploading the Arduino Sketch?
- You should remove it while uploading the sketch and reconnect it while you run the MulticolorLamp application.

THIS PROJECT WORKS PERFECTLY WELL. ONE OF THE VISITORS HAS SENT THIS PICTURE.

READ ABOUT MULTICOLOR LAMP WITH CUSTOM BLUETOOTH ID.









24 Comments for: Multi color Lamp using Amarino, Android and Arduino

connecting an android phone to an arduino via bluetooth « Which Light

[...] values from the arduino and plotting them on the phone (so arduino –> android), and the MultiColorLamp tutorial covers sending data from the android to the arduino (so android –> arduino).   [...]

mike

Sir does this thing work on Asus Eee pad transformer tf101 – Android 4.0?

i followed everything but when im going to run as android application in my tablet it says that MultiColorLamp has stopped working..

please help.. :( (

majdi

Anyone have a simple eclipse and arduino to on off an 8 LED? i really wana try control in with android bluetooth to arduino. Any willing to share can mail me any url or source code. Thanks hack4fun.fun@gmail.com

alvaro

it works, but i had to change some things.
1. I downloaded the apk from http://code.google.com/p/from-arduino-to-android-to-arduino/downloads/detail?name=MultiColorLamp-1.apk&can=2&q=
i put my bluetooth mac adress in the textbox

2. I loaded mulicolorlamp into arduino IDE , but i changed this part
meetAndroid.registerFunction(red, ‘o’);
meetAndroid.registerFunction(green, ‘p’);
meetAndroid.registerFunction(blue, ‘q’);

to this one

meetAndroid.registerFunction(red, ‘r’);
meetAndroid.registerFunction(green, ‘g’);
meetAndroid.registerFunction(blue, ‘b’);

and thats all … :)

ADs

hey ,
Can u give a tutorial with the use of usb instead of bluetooth please.

willevis

I’ve done all the steps you say there, but when I go to the step 7,after I open the MultiColorLamp.java it shows me three errors:
The method onProgressChanged(SeekBar, int, boolean) of type MultiColorLamp must override a superclass method MultiColorLamp.java /MultiColorLamp/src/edu/mit/media/amarino/multicolorlamp line 115 Java Problem
The method onStartTrackingTouch(SeekBar) of type MultiColorLamp must override a superclass method MultiColorLamp.java /MultiColorLamp/src/edu/mit/media/amarino/multicolorlamp line 124 Java Problem
The method onStopTrackingTouch(SeekBar) of type MultiColorLamp must override a superclass method MultiColorLamp.java /MultiColorLamp/src/edu/mit/media/amarino/multicolorlamp line 129 Java Problem

could you tell what can be wrong ?

Thank you!

    willevis

    i managed to make it work when i delete @Override,thanks all the same!

Rushh

Hi, has anyone of u encountered problem updating a new sketch? i tried changing the pin from 9 to 10 in the code, uploaded the sketch but it just doesnt override the previous code. My LED still function from pin 9 and not 10. Any one has an answer?

Rushh

Hi, im using HTC Desire HD 2.3.5 …i cant install the Multicolor Lamp app on my phone. Its says on eclipse that it has succesfully installed the apk in to my device…But i don’t see the app in my HTC…need help asap! thanks!!!

Oscar

excellent tutorial! only one question: what if i dont want to use the BT module and i only have the usb cable?

    buildcircuit

    I will soon write tutorial about how to control the lamp with USB cable. Thanks for the comment.

Bluetooth-controlled 3-color lamp « postapocalypticresearchinstitute

[...] am using a very nice and convenient framework for this: Amarino, and basically followed one of the tutorials that are featured there to build a christmas decoration that I can control with my Android [...]

Bogenfreund

Hey, thanks a million for the great tutorial! I got your example running on my Arduino Uno with the Bluetooth shield from iteadstudio (v2.2) and a HTC Legend (Android 2.2) without problems. :) Here is a picture of my setup: http://i.imgur.com/qSl32.jpg
Thanks for sharing!

Luis

Firstable thank you for that post , it has been very helpful to me.

I’ve done all the steps you say there, but when I try to “run as android application” it shows me those errors. Everything else worked.

Error generating final archive: java.io.FileNotFoundException: xxx\bin\resources.ap_ does not exist

Unparsed aapt error(s)! Check the console for output.

could you tell what can be wrong ?

Thank you!

Steve

can i use an other BT device for this project or only the bluesmirf device?

    CIRCUIT-BLOG.COM

    I believe that you can also try with other bluetooth devices, but the main point is to have a serial communication(RS232) with the microcontroller. You need to have TX and RX pins, that’s all. So, before you buy a module, read the specifications of both modules. However, it is always easier to try with a tested module and later try with something new.

murat

I did all of them, I can connect to bluetooth but arduino didn’t recieve my command. What can be wrong?

Eric

You didn’t use a resistor in your circuit. Too much current is going thru the LEDs and they’re going to burn out after a short while if you keep using it like that. A 150 Ohm resistor for each LED would work just fine.

    CIRCUIT-BLOG.COM

    Yes, you can put 150- 250Ohm resistor.





Leave a comment





 

UserOnline

© BUILD CIRCUIT 2012 - BuildCircuit.com is owned and operated by Sagar Sapkota. www.buildcircuit.org is the business site of BuildCircuit.