Android Bluetooth joystick

OK

Just install Version 2.3, and let me know the outcome. You should now have a Menu button available for establishing connection.

Next step is to get your BT board connected. With a JY-MCU type, the on board LED should change from blinking to solid red

I think that version 2.3 works but I don't see anything on the Serial Monitor after changing #define DEBUG from false to true. I can connect my tablet to the Arduino UNO board with Bluetooth module but the Pin 13 LED doesn't work when I touch the buttons next to the "joystick". The values change when I move the "joystick". The LEDs on the Bluetooth module changed from flashing red to non-flashing green.

OK

Please check those 3 points:

1) Arduino sketch Add Serial.println("***"); as the last line of setup() Please confirm the stars are displayed on the serial monitor

D0 should be disconnected to allow sketch upload (and reconnected afterward ;))

2) Hardware connection please refer to message #4 Only 3 wires 5V to 5V GND to GND TX board to D0 (Arduino RX)

3)BT board Baud rate Some BT boards default to 19200BPS Please adjust "Serial.begin(9600)" and Serial Monitor Baud rate accordingly Should you require it, I will upload an Arduino sketch for checking BT board Baud rate and/or setting a new value. This sketch also insure that the BT board is OK

Please send me the sketch that for checking and setting Bluetooth baud rate. I added

Serial.println("***");

as the last line of setup() and the stars show up on the serial monitor.

Here it is
This sketch will scan the BT board and display actual Baud rate and firware rev level
The menu also allows to change Baud value
I suggest to set the board @57600

Connection:
TX BT board pin to Arduino D2
RX BT board pin to Arduino D3
5V BT board pin to Arduino 5V
GND BT board pin to Arduino GND

Finally, for joystick operations:
adjust Serial.begin(XXX) in AndroLED V5
reload sketch
move D2 cable to DO
remove D3 cable
and you should be all set 8)

Tested with JY-MCU rev1.05 HC-06 (LINVOR)
Should work with any board
EDIT: doesn’t work with Bluetooth Mate Silver board
EDIT 2: another sketch has been developped for HC-05 board

Please confirm actual BT board Baud rate and firmware rev level

JY_MCU_Config.ino (3.17 KB)

The Arduino sketch is attached to the previous message You may not have access to it if you browse this forum using a tablet Please download using a PC, alternatively I can include the sketch code within a new post

Searching ............ ERROR: Bluetooth Module not responding! Make sure there are no active bluetooth connection and try again

this is the Baud rate testing setup, please check:

This is a screenshot of the expected info:

Searching ............ ERROR: Bluetooth Module not responding! Make sure there are no active bluetooth connection and try again

For checking/setting Baud rate, the BT card should not be connected (Bluetooth connected) to the tablet/Android device, To enter AT command mode, the BT card LED should blink

Just in case, try inverting D2 and D3 cables

Have you already successfully used this board for other projects ?? Please let me have a link to the specific BT board you purchased

https://www.sparkfun.com/products/10393

https://www.sparkfun.com/products/10393

Have you already successfully used this board for other projects ?? JY_MCU_Config configuration sketch won't work with this board as initialization strings are different

The datasheet for your board is here Please have a look at page 5 Default Baud rate is 115200 Modify AndroLED V5 sketch setup() accordingly, should be OK

I just bought an Android tablet with BT [off brand CN thing] to try using BT with my robots. I know this is asking a lot, but is it possible to get the joystick app, as well as maybe Sena BTerm, somewhere other than on Google Play? I just find that signing up for Google Play is very intrusive, and requires giving them personal info that I really don't want to part with, bummer. Every single Android download website I've looked at forwards you to Google Play. What a great world.

Other than that, the BT Joystick app looks really cool, :-).

Let me have your email address via PM

Done.

Check your mail :wink:

Hey kas, thanks. Just an update. I received the joystick apk, and got it installed and running on my new Android tablet. I also have a couple of BT modules which are virtual clones of the JY-MCU, and your app pairs ok. Tomorrow, see if I can get the Arduino-BT side of things to go, shake a servo. Cool, :-).

Thanks for the feedback, please keep us updated :)

Tomorrow, see if I can get the Arduino-BT side of things to go, shake a servo. Cool, :-).

do not use SoftwareSerial together with the servo library, doesn't work Just use hardware serial. You will still be able to display debug info's on the Serial Monitor

Yeah, thanks. I’ve had very poor luck with SoftSerial in the past so will try different things. I do have 1284 boards with 2 UARTs. Also, I did get the little BT dongles to pair with my tablet, and talk to terminal emulators a couple of days ago, but the AT cmds didn’t fully work [only the ‘OK’ part], plus they won’t intercommunicate, so I need to wring that all out. It’s always a muckaround with this stuff.

Hi kas, here’s an update - everything works A-Ok. Very cool.

I am running the Arduino sketch shown in your original post, except that I am using an ATmega1284P with 2 UARTs, so the BT data comes in on Serial1 and goes out Serial to the terminal emulator. Joystick, haptic, and button on/off all work good. The control menu on my tablet is as shown in reply #9.

The only question I have is that, when the joystick is at rest position shown as (0,0) on my tablet, the data received at the Arduino end = 60,60, and then it goes from 10…110 as I move the joystick. Obviously, the data range is set to -50,+50. So, what’s the 60,60 business, I didn’t see it mentioned anywheres?

Here is my system:

  1. ATmega1284P board.
  2. BT module = generic clone:
    http://www.amazon.com/Arduino-Wireless-Bluetooth-Transceiver-Module/dp/B0093XAV4U/
  3. 7" tablet, quadcore 1.3Ghz, Android 4.2.1, 1280x800 res, joystick display snapshot is attached.
    http://www.walmart.com/ip/Hisense-Sero-7-Pro-7-Tablet-Quad-Core-Processor-with-8GB-Memory/24805142

Hi kas, here's an update - everything works A-Ok. Very cool.

Thanks for the feedback

The only question I have is that, when the joystick is at rest position shown as (0,0) on my tablet, the data received at the Arduino end = 60,60, and then it goes from 10...110 as I move the joystick. Obviously, the data range is set to -50,+50. So, what's the 60,60 business, I didn't see it mentioned anywhere?

OK, this is the story ;)

I am working on V2.4 that will include a calibration screen for fine tuning This will allow a -10 +10 correction for the Joystick Zero position I want to fit the transmitted data on a signed Byte, as a positive value (0 to 128) The maximal range including calibration is -60 to +60 By adding a 60 offset, transmitted data is now 0 to 120, uncalibrated Zero position being 60,60

So far I was unsuccessful transmitting negative values. Any smarter solution ??

FYI "Option/Data Display/actual sent Bytes", will display actual transmitted value

Hi kas, I got the Android Joystick Commander controlling pan’n’tilt servos connected to my ATmega1284 Arduino board this morning, pretty cool. The one thing I might suggest is providing a shorter Refresh Interval in the Advanced Options menu, eg as little as 20 or 40 msec if possible, then the servo responsiveness would be maximal.

I looked at your data protocol some more, and think it’s pretty good the way it is. You use 1-byte to send both control codes and data, so I wouldn’t worry about trying to send signed data. It’s easy enough to subtract off the offset = 60, once you know what the coding is.

Also, I think the resolution of +/-50 ultimately producing +/-500 usec servo pulse changes is ok, considering you’re doing the control manually by moving the on-screen joystick. After all, 10-usec is only 0.9 deg of servo movement.

All in all, nice job, :-).

My next task is learning how to write my own Android BT apps. BTW, can you tell me which tools you used?

EDIT: thinking of the coding a little more, you could actually scale it up to 120 +/-100 and get 2X the current servo movement resolution, and still have space left over at the low end for the various control codes. This would give 0.45 degree servo resolution, although it probably wouldn’t be noticeable when using the joystick. OTOH, you’d have an improved format that could also be used by other Android apps for control of the same Arduino h.w. systems, without having to change the latter’s code.

EDIT2: FYI, this afternoon, we loaded Joystick Commander into a friend’s Samsung Galaxy 3 cellphone running Android 4.1, and it worked perfectly in commanding my BT-Arduino1284 board and servos, so everything good. He was impressed, and not even an Arduino guy.