Using android mobile to control arduino

I've just tried that ... It's still not working :s Its working fine with blueterm app... but when I try with the app inventor app it connects fine to my bluetooth module but when i press the buttons nothing happens...

do you have a better idea for me to debugg this code?

thanks so much for answering!

do you have a better idea for me to debugg this code

You should have tested communication of both devices, that is use Putty/Serial monitor and a USB bluetooth dongle to: A) check if the arduino responds to manually entered commands B) see what does the phone and app send

I understand you did A, but you didn't do B.

The two procedures pretty much help in 95% of cases

EDIT Ohh and I double checked your project and I just found out another error. You'll see what I mean when you do what I described above

thanks! Actually I made my app work 2 days ago before I saw your answer . I don't know why I didn't figured out that before it was pretty easy bug to fix ... :) thanks for your help (yeah that was my mistake: " the problem was that your app was sending bytes and arduino was expecting integers")

All the best, Rui Santos

I'll add a new example app soon - I still have to film it. Support for sliders has recently been added so I just want to show you how to use them to control RGB lights (and how to send several values using send string and parse int on arduino side)

ohh and if you have any suggestions or ideas for apps feel free to post them - I am running out of ideas :)

kerimil: I'll add a new example app soon - I still have to film it. Support for sliders has recently been added so I just want to show you how to use them to control RGB lights (and how to send several values using send string and parse int on arduino side)

ohh and if you have any suggestions or ideas for apps feel free to post them - I am running out of ideas :)

Thanks Kerimil! I finished my project a few days ago... (you can watch it here: http://randomnerdtutorials.com/arduino-control-2-dc-motors-via-bluetooth/)

And by the way, please read the P.P.S.

Thanks again for your awesome help!

Thx santos - I am glad I could help

Here is the new video →

It’s really basic
the arduino sketch is here:

// pins for the LEDs:
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;

void setup() {
  // initialize serial:
  Serial.begin(19200);
  // make the pins outputs:
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  Serial.setTimeout(50);
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int red = Serial.parseInt();
    // do it again:
    int green = Serial.parseInt();
    // do it again:
    int blue = Serial.parseInt();

    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {
      // constrain the values to 0 - 255 and invert
      // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
      red = 255 - constrain(red, 0, 255);
      green = 255 - constrain(green, 0, 255);
      blue = 255 - constrain(blue, 0, 255);

      // fade the red, green, and blue legs of the LED:
      analogWrite(redPin, red);
      analogWrite(greenPin, green);
      analogWrite(bluePin, blue);

   
      
    }
  }
}

Obviously you might have to change baud rate if your module uses different

rgb_1.apk is the app
rgb_1.zip is a source file for use with app inventor (to upload the source it into app inventor you have to click on more actions button right next to to new button you use to create new projects - there is an option upload source. Just select it an upload the file)

Wiring is almost exactly the same as in here → http://arduino.cc/en/Tutorial/ReadASCIIString
but I used pins 9,10 and 11 instead of 3,5 and 6.

NOTICE
If you’re not logged in as a member here you can’t see the attachments so you can’t download them. I just realized this problem. So if for the aforementioned reason you can’t see the files just try this link instead ->>
https://drive.google.com/folderview?id=0B_PfPoEotOF8N2JwT3RSX011SjQ&usp=sharing

rgb_1.apk (1.26 MB)

rgb_1.zip (3.82 KB)

http://speedy.sh/63Q9N/bluetoothforarduino-app-2.apk

kerimil, please, upload again...

edit

I found the correct download link.

That's the project I've made with the help of Kerimil. Take a look below! you can download everything at my website:

http://randomnerdtutorials.com/arduino-control-2-dc-motors-via-bluetooth/

http://www.youtube.com/watch?v=3RsfA6ngLdQ

Hi!!..thanks for this application...whenever I connect my android phone to bluetooth device to arduino uno it shows a runtime error : Need bluetooth _admin permission :neither user 10116 nor current proces has android.permission.BLUETOOTH_ADMIN...please help.. I am using HC-06 bluetooth module. It gets paired normally but not using this application.... Please help!!

kevindomadia: Hi!!..thanks for this application...whenever I connect my android phone to bluetooth device to arduino uno it shows a runtime error : Need bluetooth _admin permission :neither user 10116 nor current proces has android.permission.BLUETOOTH_ADMIN...please help.. I am using HC-06 bluetooth module. It gets paired normally but not using this application.... Please help!!

AFAIK that's problem with your device. Apparently for some reason bluetooth SPP is blocked on it. Probably rooting the phone might help but I never tested that. Other people who reported the same problem just used a different device

New update coming soon. This time a major one - I decided to switch to ethernet rather than a bluetooth communication. There are a couple of reasons for that... First of all, I found a cheap ethernet module (ENC28j60) that's roughly $6 a piece and a good library for it (not the standard one) - that's more less as cheap as the cheapest bluetooth modules. Secondly, it eliminates the need to have a separate android device to serve as a relay between arduinos and the internet - that gets annoying when you want to have a remote temperature sensor at home. What's more, I think it will be easier to understand and troubleshoot than bluetooth communication since everything is more transparent (some ppl just couldn't understand that it's good to see what's being sent). Finally, it allows to use all the different devices to access arduino (not just android devices, but computers and apple/ windows phone devices as well.... though that's through a browser not an app created with MIT's app inventor, but it's nice to have that option)

Not sure if I post it here or in a separate thread - probably in a seperate one because I am afraid it will get confusing after a couple of pages and ppl might fail to notice that there are completely two different methods.

Hi guys if anyone just wants an android app for switching relays then here's a nice free app iv'e written. https://play.google.com/store/apps/details?id=com.lovejoysa.btswitch

hi i found you artical, good stuff, i tried downloading the app inventor source code, but it seems it wont work in app inventor 2, any ideas ?

Just use the previous version. Upload it there and see how it works, you can replicate it in appinventor2 in a few minutes once you understand what's needed.

Also as far as I know Appinventor 2 doesn't have any new features yet and its GUI is almost identical

Here you can access the standard version http://beta.appinventor.mit.edu/

Great write-up, thanks for sharing! It is annoying that App Inventor does not offer a conversion tool. I used App Inventor 2 to create a basic remote for my test robot. Video and the code are here: http://42bots.com/showcase/arduino-robot-controlled-from-an-android-phone-via-bluetooth/

Hi, I work on similar project. I would like controlling lamps by RF emitter via android app/bluetooth. I have found sketch "HE300 Automatic Protocol Transmitter 'Simulator' " for replace my chacon remote on Homeeasy page: http://playground.arduino.cc/Code/HomeEasy The frame is composed of 32 bits (ON / OFF) it's works great.

Now I would like send frame by android app like you. In your case, you make pin on high or low but how I can send the chacon frame composed of 32 bits?

Thank you!

Hi Kerimil, I've tried to load your file, but seems impossible the current App inventor release do not support .zip file format, only suffix .aia format is supported, and the blocks code are not compatible.

do you have please an .aia release

Thanks

No, I don't. My advice ?? open the old file using the old version of app inventor, see what blocks are used and what they do and then replicate it in the new version

Hi Kerimil! Your project is wonderful but since you look for new ideas how about mixing your circuits and make one program that can control, let's say 9 different lamps, with indicators ON/OFF and when you switch one you can dim it!

Hi kerimil how to get LED indikator off or ON Status to show in android app?