Go Down

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

kas

Same question, same answer, see reply #482

alexander1978

Why not  :)

This a screen shot of "Total RC Commander" V0.1B:

The application is working but for the moment, the screen is optimized only for a 8" tablet
I suspect the application needs at least 7" to display the information correctly
sorry, no phones  :~ :~

Do you have a tablet ??
Please let me have size and resolution


kas

Time has passed  ::)

Total RC Commander V5.2  is now fully optimized for smartphone




I access it daily using my Motorola Moto G



vlad-sh

#498
May 05, 2015, 07:08 am Last Edit: May 05, 2015, 07:40 am by vlad-sh
Hi Kas,

Thank you for useful "Joystick BT Commander" application.
But is it possible to ask you to add option to switch from joystick to simple keys (left, right, forward, backward and stop)?

It could be like:

If "left" key is pressed - send x=-100,y=0
If "right" key is pressed - send x=100,y=0
If "forward" key is pressed - send x=0,y=100
If "backward" key is pressed - send x=0,y=-100
If "stop" key is pressed - send x=0,y=0


Picture is attached :).



In another words, keys will be duplicate leftmost, rightmost, topmost and bottommost joystick's positions.

kas

#499
May 05, 2015, 07:24 pm Last Edit: May 23, 2015, 04:04 pm by kas
Hi vlad-sh, welcome to the Forum

This is an analog joystick emulator App
I want to keep this 90KB App as compact and efficient as possible  ;)


A possible workaround is to modify AndroTest V2.0

Code: [Select]
// within getJoystickState:                                  ** not tested **

  if      ((joyY>50)  && (abs(joyX)<25))       {joyX=0; joyY=100;}
  else if ((joyY<-50) && (abs(joyX)<25))       {joyX=0; joyY=-100;}
  else if ((joyX>50)  && (abs(joyY)<25))       {joyX=100; joyY=0;}
  else if ((joyX<-50) && (abs(joyY)<25))       {joyX=-100; joyY=0;}
  else if ((abs(joyX)<25) && (abs(joyY)<25))   {joyX=0; joyY=0;}
  else                                         {joyX=JoyX_ant; joyY=JoyY_ant;}
  JoyX_ant = JoyX;
  JoyY_ant = JoyY;

Also uncheck Options / Joystick properties / Auto return to center

Let me know if it helps


kas

#500
May 24, 2015, 10:44 pm Last Edit: Jun 03, 2015, 07:43 am by kas
As of today, this thread has been viewed 100 000 times, with 500 responses
Joystick BT Commander has been downloaded 8100 times on Google Play

Thanks for your ongoing interest  8)  8)  8)

As a celebration, I will give away 10 copies of Total BT Commander
Just contact me by email or PM

Finally, please post a photo/video showing your favorite Android controlled project




rth0

Hi vlad-sh, welcome to the Forum

This is an analog joystick emulator App
I want to keep this 90KB App as compact and efficient as possible  ;)


A possible workaround is to modify AndroTest V2.0

Code: [Select]
// within getJoystickState:                                  ** not tested **

  if      ((joyY>50)  && (abs(joyX)<25))       {joyX=0; joyY=100;}
  else if ((joyY<-50) && (abs(joyX)<25))       {joyX=0; joyY=-100;}
  else if ((joyX>50)  && (abs(joyY)<25))       {joyX=100; joyY=0;}
  else if ((joyX<-50) && (abs(joyY)<25))       {joyX=-100; joyY=0;}
  else if ((abs(joyX)<25) && (abs(joyY)<25))   {joyX=0; joyY=0;}
  else                                         {joyX=JoyX_ant; joyY=JoyY_ant;}
  JoyX_ant = JoyX;
  JoyY_ant = JoyY;

Also uncheck Options / Joystick properties / Auto return to center

Let me know if it helps


Hi kas,

Thanks for this awesome work.

I think you might have misunderstood vlad-sh as I've recently run into a situation where I need  to control something with Joystick BT commander using keystroke. I use one of these old android phone with a fancy slide-out-full-querty-with-direction keyboard so I was also wondering if I could use they keypad to send frames to the arduino. Thus the full left-right-up-down (and possibly some combination).

I don't think that it'd be hard to implement such a feature? I would help implementing it if I can fork the project but since the source is not open, ... or if the project is available in the form of "importable" jar package then it would even be better.

Let me know your thought.
Cheers

kas

#502
May 31, 2015, 10:35 pm Last Edit: May 31, 2015, 10:36 pm by kas
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



jak97100

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

kas

Hi Jak, welcome to the Forum  :)

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 ??


jak97100

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

kas

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


Quote
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

Code: [Select]

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



jak97100

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!

jak97100

#508
Jun 27, 2015, 10:47 pm Last Edit: Jun 27, 2015, 10:51 pm by jak97100
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.

kas

#509
Jun 28, 2015, 07:46 am Last Edit: Jun 28, 2015, 07:49 am by kas
Quote
The code does work and gives me this as output on the Serial Monitor:
" Test Soft_Serial
2504848504848325048485048483250484850484832504848504848325048485048483250484850484"
So far so good  ;)
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 ??




Go Up