Pages: 1 ... 4 5 [6] 7   Go Down
Author Topic: Using android mobile to control arduino  (Read 81970 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as I said tens of times in this thread: get a bluetooth dongle and use a terminal program (such as putty) to check if:
A) the app is sending
B) the BT module reacts to manualy entered commands (through serial)

But even before that check if TX pin on the BT module is connected with RX pin on arduino
Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi kerimil.
First I would like to say thanks so much for sharing your work!
I would love if you could help me...
I'm working on a project similar to a previous project I've made a few months ago (you can visit my website to check my project http://randomnerdtutorials.com/arduino-control-dc-motor-via-bluetooth/)

In my previous project I was controlling one DC motor... But now instead of controlling one DC motor I want to control 2 DC motors... my code is working perfectly when I'm using the BlueTerm app for android. (BlueTerm app is similar to putty it sends information to my arduino via bluetooth....) And my circuit is pretty much the same as the one i've showed on my website... I just added another motor... My circuit is working perfectly because it works with the serial monitor (when i send 1,2,3,4,5... and when I send via blueterm app those numbers)

And I want to create an App to send that same information to my arduino but with MIT App Inventor...
here is my arduino code: http://randomnerdtutorials.com/wp-content/uploads/2013/08/sketch_aug29a.zip
here is my Mit App Inventor code: http://randomnerdtutorials.com/wp-content/uploads/2013/08/blue.zip

I've tried to replicate your code to my project but It's not working. (I'm using HC-05 Bluetooth Module)
I can't find out my problem and I've searched a lot...

My app connects fine to my bluetooth module but when I click forward, left ... nothing happens.
So It's a problem with my app... somethings is missing...

Could you please take a look at my code and project?
And try to help me out I would be really thankful! I want to share this project with my friends on randomnerdtutorials and of course I will give you credit for helping me out!!

Thanks again and best regards,
Rui Santos

P.S. I would like that my app looks similar to this: http://randomnerdtutorials.com/wp-content/uploads/2013/08/d.png
Logged

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see you haven't set delimiter byte

It's under components - select BluetoothClient1 and there you can enter delimiter byte. Set it to 13 and see if it helps.
Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: September 03, 2013, 07:47:49 am by kerimil » Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ... smiley
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
Logged

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley

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

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thx santos - I am glad I could help


Here is the new video ->

It's really basic
the arduino sketch is here:
Code:

// 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 (1288.43 KB - downloaded 162 times.)
* rgb_1.zip (3.82 KB - downloaded 178 times.)
« Last Edit: September 30, 2013, 11:51:02 am by kerimil » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

kerimil, please, upload again...

edit

I found the correct download link.
« Last Edit: September 30, 2013, 02:15:57 pm by spline » Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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/

Logged

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Nottingham, England
Offline Offline
Newbie
*
Karma: 0
Posts: 4
1976
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 ... 4 5 [6] 7   Go Up
Jump to: