Android Bluetooth joystick

Hi rth0,

Sorry, for personal reasons, I won't release the code in a foreseable futur
You may check Google Play for similar Apps

Cheers

Hi Kas,

I am having trouble reading the values from the app to my computer through an HC-06 BT module attached to my uno. I used ur code but it still didn't work. Please help asap! Thanks

-Jak

Hi Jak, welcome to the Forum :slight_smile:

Which Android device are you using (+ Android version)

Carefully review those 10 questions and answer YES/NO
(If you don't understand a specific item, just tell it)

Android side (smartphone/tablet screen):

  1. go to Option/About and confirm that JBTC App version is V5.2
  2. can you move the joystick and display position at bottom left
  3. is your BT card paired with your Android device
  4. are you connected ("connected to: XXX", green text)

Arduino side:
5) are you using AndroTest V2.0 sketch
6) are Bluetooth TX connected to D2 and RX connected to D3
7) is your Bluetooth card already configured @57600 bps (most are 9600bps by default)
8 ) is your Bluetooth card LED solid red or green (blinking = not connected)
9) is your Arduino Serial monitor configured @57600 bps

Finally:
10) your Arduino Serial Monitor should anycase display:
AndroTest V2.0 - @kas2014
demo for V5.X App
does it ??

  • any additional information ??

Hi,

I have 5.2V, i can move the joystick and see the numbers change, BT is paired with my phone properly and does say connected to "JAK" (name of BT) in green

Arduino side:

i believe i am using the 5.2V sketch, tx to rx and rx to tx are connecte, my BT module is configured at 9600 but it wont allow me to change it for some reason in AT mode gives me error(0); my BT module only has a red light and it will blink every second rather than constantly when not connected. I tried changing the baud rate on the serial monitor but no results. And yes it does give me

"AndroTest V2.0 - @kas2014
demo for V5.X App"

but nothing after that. Thanks

Which Android device are you using (+ Android version) ??
Is your Arduino board genuine Uno or clone

tx to rx and rx to tx are connected .... my BT module only has a red light

Just to make sure, try inverting Arduino D2 and D3 wires
Please let me have a link to your specific BT board

Finally try this bare minimum sketch to test incoming data from your smartphone

#include "SoftwareSerial.h"

SoftwareSerial mySerial(2, 3);

void setup()  {
  mySerial.begin(9600);       // assuming 9600bps BT card
  Serial.begin(57600);
  Serial.println("Test Soft_Serial");
}

void loop() {
  if(mySerial.available())    Serial.print(mySerial.read());   
}

Bytes received by the Bluetooth card will be echoed to the Arduino Serial Monitor

Should display series of numbers:
25054505052533250545050525332505450505253325054505052533250545050525 ..................

Hi there,

Sorry for the late reply, I was really busy with family and things didnt find any time but I'm back to it again.

Here is the link to the BT board: http://www.canadarobotix.com/bluetooth/1258-hc-05-wireless-bluetooth-module

The code does work and gives me this as output on the Serial Monitor:
" Test Soft_Serial
2504848504848325048485048483250484850484832504848504848325048485048483250484850484"

Pin 2 goes to Tx of BT and pin 3 goes to Rx of BT.
Thanks!

Also,

after that test, i am able to change the baudrate of the BT to 57600 successfully. Before I was using the AT+UART7 command but that is for the HC-06 BT. Instead I used the AT+UART=57600,0,0 command and it worked properly. The code you provided for testing in your latest reply still works and gives those values.

Note: I thought my BT was HC-06 but its actually the HC-05.

The code does work and gives me this as output on the Serial Monitor:
" Test Soft_Serial
2504848504848325048485048483250484850484832504848504848325048485048483250484850484"

So far so good :wink:
Communication is OK, probably a parsing problem

Please run the attached debugging sketch and post back the Serial Monitor output
(you need to be logged to see the file)

Which tablet/smartphone are you using (+ Android version) ??
Is your Arduino board genuine Uno or clone ??

AndroTest_V20_POSTED_DEBUG.ino (9.25 KB)

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

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

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?

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 :stuck_out_tongue:

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

"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 :smiley: 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?

Its working perfectly now

. :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

to add in my own changes to the code, do i do it in the joystick function?

Yes, within getJoystickState()

Also, can I speed up the response time?

Not sure to understand, please elaborate

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

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 :wink:

When ready, show us your new toy

This is my new App :sunglasses: :sunglasses: :sunglasses:

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

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

woodygb:
I'll keep an eye on your progress Kas

Hi Woody, nice to see you again :wink:

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.

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