Go Down

Topic: Android Bluetooth joystick (Read 361265 times) previous topic - next topic

jak97100

Im using my phone, Nexus 5, has the 5.1.1 Android version. My arduino is an remeo V1.1 but acts like the uno.

Link: https://www.bananarobotics.com/shop/image/cache/data/sku/BR/0/1/0/2/2/BR010223-DFRobot-Romeo-All-In-One-Robot-Controller-V1.1-with-ATMega328p/DFRobot-Romeo-All-In-One-Robot-Controller-V1.1-top-600x600.jpg

Im trying the code and will post back. Thanks

jak97100

#511
Jun 28, 2015, 08:21 am Last Edit: Jun 28, 2015, 08:25 am by jak97100
Good news, The values change with the Joystick!!!
Is there a simplified version of this code, Im just using the app to control a motor and servo with the joystick, for an RC car and I just need one way communication? Since you said this is the debug code. Thank You so muchhh!!!! :)

Here is some of the code from the serial:

"AndroTest V2.0 - @kas2014
demo for V5.X App (6 button version)
1   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
2   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
3   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
4   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
5   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
6   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
7   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
8   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
9   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
10   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
11   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
12   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
13   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
14   Joystick: < 2 50 48 50 50 48 48 3 >   0-0-0
15   Joystick: < 2 50 49 55 50 48 53 3 >   0-0-0
16   Joystick: < 2 50 51 53 50 48 55 3 >   0-0-0
17   Joystick: < 2 50 54 55 50 48 52 3 >   0-0-0
18   Joystick: < 2 50 56 54 50 48 51 3 >   0-0-0
19   Joystick: < 2 50 57 57 50 48 50 3 >   0-0-0
20   Joystick: < 2 50 57 57 50 48 49 3 >   0-0-0
21   Joystick: < 2 50 57 57 50 48 48 3 >   0-0-0
22   Joystick: < 2 50 57 57 49 57 55 3 >   0-0-0
23   Joystick: < 2 50 57 57 49 56 55 3 >   0-0-0
24   Joystick: < 2 50 57 49 49 54 50 3 >   0-0-0
25   Joystick: < 2 50 55 50 49 51 50 3 >   0-0-0
26   Joystick: < 2 50 51 55 49 49 49 3 >   0-0-0
27   Joystick: < 2 49 57 55 49 48 56 3 >   0-0-0
28   Joystick: < 2 49 53 55 49 49 57 3 >   0-0-0
29   Joystick: < 2 49 50 50 49 51 57 3 >   0-0-0
30   Joystick: < 2 49 48 56 49 54 53 3 >   0-0-0
31   Joystick: < 2 49 48 50 49 56 53 3 >   0-0-0
"

updates with the joystick movement, but i can barely tell cause the value range is from 40-60 im guessing?

kas

Quote
Im using my phone, Nexus 5, has the 5.1.1 Android version. My arduino is an remeo V1.1 but acts like the uno.

Nice board  :P




Quote
Here is some of the code from the serial:

"AndroTest V2.0 - @kas2014
demo for V5.X App (6 button version)
1   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
2   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
3   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
4   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
5   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
6   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
7   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
8   Joystick: < 2 50 48 48 50 48 48 3 >   0-0-0
  . . . . . . . .
:o  :o
Android/Arduino communication is strickly koscher (protocol)
I understand now you were not using the _original_ AndroTest V2.0 demo sketch
Please run it and confirm you can display joystick position (-100 +100 range) within the Serial Monitor





jak97100

#513
Jun 28, 2015, 10:18 am Last Edit: Jun 28, 2015, 10:19 am by jak97100
"AndroTest V2.0 - @kas2014
demo for V5.X App (6 button version)
Joystick position:  0, 0
Joystick position:  0, 0
Joystick position:  0, 0
Joystick position:  0, 0
Joystick position:  7, 1
Joystick position:  25, 10
Joystick position:  40, 31
Joystick position:  53, 57
Joystick position:  59, 79
Joystick position:  57, 81
Joystick position:  56, 82
"

Its working perfectly now :D Thank you so much! Yeah, I believe i was using the older version of your code and didnt have my BT at the correct baud rate. So to add in my own changes to the code, do i do it in the joystick function? Also, can I speed up the response time?

kas

Quote
Its working perfectly now
.    :)  :)  :)  :)  :)



Quote
to add in my own changes to the code, do i do it in the joystick function?
Yes, within getJoystickState()



Quote
Also, can I speed up the response time?
Not sure to understand, please elaborate






jak97100

So on the app with the code running on the uno, If I hold the joystick right let's say, on the serial monitor it will show me 99 I think and will show me 99 again for the next update and then 99 again for the next time it calculates it. But that update time is around 500ms or 250ms I think but is there a way to make it update faster let's maybe? Cause I'm gonna use the joystick for a DC motor, 6Amp motor and iif it has a small delay in communication between the joystick app and Arduino then it would be perfect! So is there a possible way? Thank you for ur help I appreciate this a lot! :)

kas

#516
Jun 28, 2015, 11:14 am Last Edit: Jun 28, 2015, 03:31 pm by kas
Quote
But that update time is around 500ms or 250ms I think but is there a way to make it update faster let's maybe?
By default, data is updated 20 times per seconds (50ms) if joystick data has change
If joystick hasn't moved, data is updated every 10 intervals (500ms), to save phone battery

You can change this default behavior
Go to Option/advanced user,  'Refresh Interval '  and  'Timeout Count'
Adjust to taste  ;)


When ready, show us your new toy




kas

This is my new App  :smiley-cool:  :smiley-cool:  :smiley-cool:

MQTT Commander can switch a light bulb or any appliance from anywhere in the world, using an Android smartphone



More infos in the home automation section



woodygb

I'll keep an eye on your progress Kas. :)

kas

#519
Jul 31, 2015, 06:49 am Last Edit: Jul 31, 2015, 06:53 am by kas
I'll keep an eye on your progress Kas
Hi Woody, nice to see you again   ;)




shuvo915

Hi, I am trying to use the app to control my arduino nano based robot.
I am having problems with the buttons and receiving feedback from the arduino. After the initial data sent by the arduino the app doesn't update. The buttons turn off and if enabled turns off again. On the arduino side i have checked that the data was being sent and received correctly as per described protocol. The arduino was saving button status correctly and sending them back at regular intervals (750ms).
But on the app the data fields were not being updated and the buttons were turning off.

kas

#521
Sep 07, 2015, 07:05 am Last Edit: Sep 07, 2015, 07:08 am by kas
Hi shuvo915,

From your description, I understand that smartphone >> Arduino communication is OK
but Arduino >> smarphone communication is failing


Which  Android device are you using + Android version
Confirm BT Commander App version (Option/About...)

Is your Nano clone or genuine Arduino
What is your BT card baud rate

Please upload the _original_ AndroTest V2.0 demo sketch in your Nano,
move joystick, press buttons, and let us have a Serial Monitor printout





scandermore

Hello Kas.

 I am building now my first robot and I am sure that your program will be very useful, as it is not only limited to move forward and backward, like most of the arduino be controllers I have seen in Google play. The explanations and the protocol are very straightforward and easy to understand. Thanks for all the job to the community.

 I would like to suggest only one thing, as I am planning to grow up my robot in short time: would it be possible to add another Joystick, to move another pair of axis? The typical use would be a camera with pan and tilt servos. The communication protocol should be modified, but I think it would be possible to add another type of message, to keep the compatibility.

 Thank you, and good luck with all your projects!

 Alex

kas

#523
Sep 21, 2015, 08:27 am Last Edit: Sep 21, 2015, 08:35 am by kas
Quote
Hello Kas.
 I am building now my first robot and I am sure that your program will be very useful, as it is not only limited to move forward and backward, like most of the arduino be controllers I have seen in Google play. The explanations and the protocol are very straightforward and easy to understand. Thanks for all the job to the community.
Thanks Alex  8)


Quote
I would like to suggest only one thing, as I am planning to grow up my robot in short time: would it be possible to add another Joystick, to move another pair of axis? The typical use would be a camera with pan and tilt servos. The communication protocol should be modified, but I think it would be possible to add another type of message, to keep the compatibility.
As already mentioned, I want to keep the App as simple as possible
Sorry for that  ::)



@all
I am busy preparing  Joystick WiFi Commander, a Wifi enabled App for the new ESP8266 module.




This little board is available for 3 bucks shipped

Joystick WiFi Commander should behave as Joystick BT Commander, by just replacing the HC-O5 Bluetooth module by the ESP8266 WiFi board.
You will then be able to control you favorite bot from anywhere in the world  ;)  ;)  ;)



scandermore

 OK, thank you for your hard work. Maybe you could consider to add it in the future to the other app (the one that shows also the video. That would make sense, as then you could move the robot and the camera PAN and TILT :-)

 I will keep an eye to the wifi board and app. Just have to change all the mechanics of my robot, as I was using an old cybot, and the drivers and motors were not very good. Planning to do a balancing robot also, so I will be using your app to control both of them. Thank you!

 Alex

Go Up