Android Bluetooth joystick

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

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.
    Robot or human?

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

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.

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.

Easy to do... let's see...

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

Android programming is a fascinating universe
Three very different approches are available on the market, with increasing learning curves
App Inventor
A full graphic cloud based application, just fitting together puzzle pieces
still in development, very intuitive but a bit limited for the moment

Basic4android
using a syntax MS Visual Basic syntax, creates native Android applications

Eclipse + Android SDK
for full blown applications, a bit frustrating at startup :astonished: :astonished: :astonished:
A first experience with Java will definitly help
Tons of help and snippets, at XDA developpers
lots of tuto's on Youtube

I tried App Inventor and finally choosed the hard way... 8)

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.

Thanks for this excellent feedback :slight_smile:

Out of curiosity, where is the Land of sun+snow ??

Thanks for the dev tool info, will look them up.

BTW, the Galaxy phone guy [non-techie] was totally amazed how he could suddenly use his Android phone to control the world, ;-), ie besides just placing calls and surfing the web. Land here is northern Nevada, hot and sunny desert, sitting below 11,000 foot mountain peaks covered with snow, at least in the winter. Sleep time now.

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

Easy to do... let's see...

Check your mail for V2.35
I added 25ms and 50ms
At 25ms, you may have to increase your BT board Baud rate to 57600

Edit:
I just tested V2.35 with the Pan/Tilt robot
At 25ms, movements are much smoother :slight_smile:
I will upload this version to Google Play later today
Thanks for your suggestion

Edit2:

BTW, the Galaxy phone guy [non-techie] was totally amazed how he could suddenly use his Android phone to control the world, ;-),

I had this very same feeling 8), this is the reason I decided to share

Edit:
I just tested V2.35 with the Pan/Tilt robot
At 25ms, movements are much smoother smiley
I will upload this version to Google Play later today
Thanks for your suggestion

Done

Hi kas, I tested the new version of Joystick Commander. The servo movements definitely are much smoother now, especially for very slow changes of the joystick position. Looks good. I also looked at the wording on all the menus like you suggested, and they all look good too, I think.

Considering BT works on the 2.4Ghz band, I'm also surprised that the servo response latency is so quick, as where I live there are about 30 routers that I can pick up. See attached. I might have expected some interference, and slower responsiveness.

The only thing left that I might comment on is that you cannot tell from the Android screen what is the state of the Led on the Arduino, in the sense that you don't know what was the last keypress made - on or off. I guess there is no option for feedback from the Arduino board back to the Android device, but it might help to put some marker on the Android screen to indicate the last key pressed. Like a little marker that comes on, separate from the on,off keys.

...you cannot tell from the Android screen what is the state of the Led on the Arduino, in the sense that you don't know what was the last keypress made - on or off. I guess there is no option for feedback from the Arduino board back to the Android device, but it might help to put some marker on the Android screen to indicate the last key pressed. Like a little marker that comes on, separate from the on,off keys.

I will have a look at it when back from holydays
My background is Process Control, in term of strategy, I agree, a feedback from the Arduino is much better
This should be feasible :roll_eyes:

Holydays? Where the heck does one go on a holiday when he lives in a resort town like you do? LOL. Maybe the beach. Bon chance.

FYI, there appears to be a bunch of BTBees around,
http://www.google.com/search?hl=en&site=imghp&tbm=isch&source=hp&biw=1025&bih=870&q=bluetooth+bee

I happen to have this one on hand, so I plugged it into my Arduino1284 board [which just happens to have a convenient XBee socket], and the JoystickCommander worked right off without any muckaround, so it looks like the "default" mode of the BTBee is the same as for the other small BT modules cited earlier. Again, 2 wire control - Rx, Tx, 9600bps, code=1234 - and go. So, versatility increases.
http://www.robotshop.com/dfrobot-bluetooth-bee-2.html

Holydays? Where the heck does one go on a holiday when he lives in a resort town like you do? LOL. Maybe the beach. Bon chance.

I wont tell it over the Web (your Big Brother is watching us) :wink:

I happen to have this one on hand, so I plugged it into my Arduino1284 board [which just happens to have a convenient XBee socket], and the JoystickCommander worked right off without any muckaround, so it looks like the "default" mode of the BTBee is the same as for the other small BT modules cited earlier. Again, 2 wire control - Rx, Tx, 9600bps, code=1234 - and go. So, versatility increases.

Good to know, thank for the information

You'll notice that most of the BTBees in those pictures use the same same BT module as the little boards we've been using, and the Bee is just a carrier board to plug into an XBee socket. And never tell anyone in public what your specific plans are, just general stuff like "Well, maybe we'll head south, or maybe east, have to see how it goes", LOL. Talk about intrusiveness, this article may be of interest! Do a google search on
"WSJ How Kid Apps Are Data Magnets". I find the direct link gets highjacked. "Big Data" knows more about you than your own govt. C'est la vie. Neuromancer in action.

And never tell anyone in public what your specific plans are, just general stuff like "Well, maybe we'll head south, or maybe east, have to see how it goes", LOL. Talk about intrusiveness, this article may be of interest! Do a google search on
"WSJ How Kid Apps Are Data Magnets". I find the direct link gets highjacked. "Big Data" knows more about you than your own govt. C'est la vie. Neuromancer in action.

I suggest to go back to the original subject of this thread
Words Google, FaceBook, NSA have nothing to do with Bluetooth control, even if European and Gaia citizens have hard feelings about that :0 :0 :0

Hoops... I heard a strange click on my phone line :disappointed_relieved:

Best not to kick the tiger in the a**, when he's sleeping. But that's old news. The WSJ article is about ggle, yah, fceb**k, amzn, and eby, the new 4-letter word agencies that know 100X more about you than the gvt will ever know. LL.

On other matters, I've started reading a book on Android development. Install about 700-800 MB of dev tools (java sdk, eclipse, eclipse android plugin, android sdk, maybe some others), and learn how they work, and maybe 3 months later you'll have a nice 47KB .apk app. More L*L.

I've started reading a book on Android development. Install about 700-800 MB of dev tools (java sdk, eclipse, eclipse android plugin, android sdk, maybe some others), and learn how they work, and maybe 3 months later you'll have a nice 47KB .apk app

You choosed the hard way :fearful: :fearful:
Bonne chance :wink: