Arduino + Java + Joystick

Interfacing your own hardware with a Java app couldn’t be easier than this example. [Pn] created this proof-of-concept using an Arduino, an analog joystick from a gaming controller, and a few lines of Java code. The Arduino reads an ADC value from the joystick’s x-axis and transmits it over the serial connection ten times a second. The Java program triggers on every serial event, parsing the data based on the @ symbol that the Arduino sends as a start and end condition.

We like this kind of example because there’s nothing extra involved. It lets you take the concept and run with it in any project imaginable. Be it a more complicated Joystick, or simple sensors that you’d like to interface with.

14 thoughts on “Arduino + Java + Joystick

  1. Nicely written project. I beg to differ regarding the easiest way to do this. If you don’t already have a ready made Arduino then Byron is way simpler as it uses the OS’s built in HID driver for USB and will happily enumerate itself as a joystick or keyboard or whatever.

    I’ve used this a couple of times. It’s great and just works for up to 6 analog channels.

  2. That said, this arduino thing is a total hack. You don’t really learn anything (who didn’t know you could read an analog input and communicated serially, who didn’t know you could interpret a serial stream on a computer). What would be COOL is him hooking up the joystick, then implementing an HID interface, so the data that is passed (over usb, not usb to serial) is meaningful to more than just one application built to read that specified @@ ‘protocol’ and uses a standard, well defined interface. Through that you could build your own game pads, etc.

  3. I’ve done something similar but more funcional.

    An arduino with a 2 axis joystick + 1 button, send the data via serial to the pc, and in the pc I use PPJoyCOM, so I can use it like a real joystick in any game.
    If anyone want the arduino code I send it, it’s very simple btw, once you figure out what PPJoyCOM expects to read from the serial port..

  4. @nes omg haha that looks horrible, but I guess you got it working.

    I’m thinking of getting a teensy to mod an xbox controller, but I need the motivation to START the project. sigh.

  5. Well done Pn, but the way to go is defo the HID crafting method. It will be also cool to build a wireless HID host receiver. So that you can build a wireless network with a usb hid node host.
    Then you can attach everything you want.
    I have some jeenodes ready to go.
    I’m gonna do that, it’s awesome!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.