Multi color Lamp using Amarino, Android and Arduino

This tutorial is for novices who have never made any Android application or worked with Amarino. If you have never done any experiment with Android and Arduino, please start with this experiment.

You don’t need to have previous knowledge of Android for doing this experiment. Simply download any Android serial emulator and upload the Arduino code and send/receive between Arduino and Android. For that experiment, you can use any kind of Bluetooth adapter, for example, BlueSMiRF or general Bluetooth adapter. If you are not confident, start with a cheap Bluetooth module, BUY HERE.

After doing this experiment, go for Amarino, because the core of Amarino is based on the experiment stated above. I strongly recommend you to work with SensorGraph project before you start doing the Multicolor lamp project. For doing SensorGraph project, please click on the following link: How to make SensorGraph

We need the following components for Multicolor lamp experiment:

a. Android Smart Phone- I used ZTE Blade. Any kind of Android phone should work.

Step 3 Set up Bluetooth adapter

Amarino is perfectly compatible with both of these modules. BlueSMiRF adapter is expensive than the general one, so, I recommend to buy the general one. BUY HERE

Connect the Bluetooth adapter in the following way:

VCC — 5V

GND — GND

TX — RX (digital pin 0 of Arduino)

RX — TX (digital pin 1 of Arduino)

NOTE: The BlueSMiRF bluetooth module should work at 9600bps and 57600bps. If it does not work at 9600bps, you can change the baud rate and try again. Here’s a tutorial for checking and altering the actual baud rate of your module.

Step 5 Set up Eclipse

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.

Step 6 Download the Multicolor Lamp folder

Step 7 Work with Multicolor 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.

**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’.

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.LaunchThis will install the Multicolor Lamp app to your phone and run it.

NOTE: If your application does not install on the 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 automatically 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 MultiColor Lamp. Set the same baud rate that you have in Bluetooth adapter.

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.

hye there, i got some problem over hear,, i managed to built the app and display color meter on my xperia e dual. the problem is the rgb light i used keep on lightning and fail to follow the app’s command.. i had also connected the amarino with the bluetooth.. please help me tq

hi i am using a samsung galaxy young model gt-s5360l using android 2.3.5 but when I run the app multicolor this crash, in fact when I uses the test this works correctly, then i dont understand what is the problem, could you help me

Hi, this is my first time trying to use android, i do all the steps that you put in this page and my program doesnt have any mistake, but when i try to download to my phone I cant, I download all the apis but i still have the problem, could you help me, I give my thank for your answers

ah, device number is shown in amarino!
First it didn’t run on my smartphone aswell, then i tagged every box left of the names in “build path -> configure build path -> java build path -> order and export” and now it works fine. COOL!

I had the same problem. Try this: Right click on Multi Color Lamp, then click on build path, configure build path, order and export tab, check the box next to the Amarino Library v0_55.jar and move it to the bottom of the list. I don’t know why this worked, but it did. On the other hand, in order for the Sensor Graph app to load on my phone, I had to move the .jar file to the top of the list.

It appears that the default speed of the dx module is (JY-MCU Arduino Bluetooth Wireless Serial Port Module) is 9600bps. I installed all the amarino apk files and used the precompiled multicolorlamp apk.

As user Alvaro, I had to change the following lines in the arduino program:
meetAndroid.registerFunction(red, ‘o’);
meetAndroid.registerFunction(green, ‘p’);
meetAndroid.registerFunction(blue, ‘q’);

hi , i m trying to make an android app to receive sensor data from arduino.
i m following the steps from multicolor lamp tutorial checked for everything.
but i cant get android to connect with bluettooth.:S
package edu.mit.media.hlt.sensorgraph;

// the device address from which the data was sent, we don’t need it here but to demonstrate how you retrieve it
//final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS);

// the type of data which is added to the intent
final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1);

// we only expect String data though, but it is better to check if really string was sent
// later Amarino will support differnt data types, so far data comes always as string and
// you have to parse the data to the type you have sent from Arduino, like it is shown below
if (dataType == AmarinoIntent.STRING_EXTRA){
data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA);

if(data != null){
mValueTV.setText(data);
try {
// since we know that our string value is an int number we can parse it to an integer
final int sensorReading = Integer.parseInt(data);
mGraph.addDataPoint(sensorReading);
mValueTV.setText(sensorReading);
}
catch (NumberFormatException e) { /* oh data was not an integer */ }
}
}
}
}

Hi! I was trying the multiColorLamp example, but I have a small issue. It crashes after installation.

In the beginning I have and error in the manifestfile. in the line for setting up the sdk .it was set to minSdkVersion=”3″ and android:targetSdkVersion=”4″ , and of couse i was not able to upload the program to my phone, but after modifying it to :
android:minSdkVersion=”2″
android:targetSdkVersion=”16″ corresponding to my target device running on android 4.04, the error disappear and I am able to upload the code. But now the app crashes after launching.

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

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

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?

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!!!

Hi, thanks for your prompt reply..i can now have the app. But when i upload the code to the Arduino Uno, the red light doesnt light up, cause from the code, once loaded, the red LED will light up right? I had tested on the default led on pin 13, it light up, so i guess my wire connection cant be wrong.

And I have already changed my Bluesmirf baudrate to 57600. Any idea whats wrong? Im stuck now. Does the baudrate matter?

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!

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.

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.