Go Down

Topic: Using android mobile to control arduino (Read 95 times) previous topic - next topic

kerimil

Feb 14, 2013, 03:36 am Last Edit: Feb 16, 2013, 10:01 am by kerimil Reason: 1
Here is my android controlled arduino project. A simple app sends data through SPP over bluetooth and switches an LED on and off.

The circuit is just a bluetooth module, arduino UNO, LED, resistor and some wires.

The LED can be switched on using buttons as well as voice activation (anything that contains the word 'on','off' or 'blink' - so saying 'turn the LED on' works as well as just uttering 'on').
I created the app using MIT app inventor and this project was created pretty much only to show how easy it is to write custom apps using the tool and interface with microcotrollers in this manner. One could use MIT app inventor to add more more features, such as using accelerometer or GPS data to control the LED, switching the state using text messages, web communication, not only send but also receive data, etc.
...well the point is - MIT app inventor is pretty cool and you should check it out


VIDEO OF IT -> http://youtu.be/41MRGjdVIMQ







Here is the app for download -> http://speedy.sh/63Q9N/bluetoothforarduino-app-2.apk

and here is the source, you can upload it to  MIT's app inventor and modify as much as you want to -> http://speedy.sh/mDyAk/bluetoothforarduino-app-1.zip

Here is the arduino code
Code: [Select]


const int ledPin = 7;      // the pin that the LED is attached to
 byte serialA;
void setup()
{
 // initialize the serial communication:
 Serial.begin(19200);
 // initialize the ledPin as an output:
 pinMode(ledPin, OUTPUT);
}

void loop() {


 
     
     switch (serialA) {
   case 1:
     digitalWrite(ledPin, HIGH);
     break;
   case 2:
     digitalWrite(ledPin, LOW);
     break;
   case 3:digitalWrite(ledPin, HIGH);
     delay(100);
     digitalWrite(ledPin, LOW);
     delay(100);
   
     
 }
}
void serialEvent(){
serialA = Serial.read();
}



Nogueira

Could you share the AppInventor project?

kerimil

#2
Feb 15, 2013, 08:04 pm Last Edit: Feb 16, 2013, 09:59 am by kerimil Reason: 1
Here is the source file -> http://speedy.sh/mDyAk/bluetoothforarduino-app-1.zip


As I mentioned on hackaday it won't be the exact copy as I improved it to react not only to 'BLINK' command but also 'FLASH' and 'CYCLE'... done that just because google voice search usually returns 'pink' or even 'd#ck' instead of BLINK :-D
but apart from that it's the same

If you have any problems with downloading the files just let me know


scheelga

This might be a noob question but what bluetooth module did you use?

sjenkins2

I just gave this a try myself and it worked great. Now I am trying to receive data (an integer value) from the arduino instead of sending to it, but cant seem to figure out how...

Go Up