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.
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.
http://1010.co.uk/org/byron.html
I’ve used this a couple of times. It’s great and just works for up to 6 analog channels.
That byron thing looks pretty cool. Like a cheaper Teensy
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.
This gave me a geek chubby. This is going to be my next project…
@Gdogg: I rats’ nested the first one I did from old junk so it cost two parts of nothing:
http://postimage.org/image/2cfmum7vo/
The teensy does look a bit better supported though.
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..
@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.
With the Uno series you could build a proper HID joystick using this method.
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!
Epokh I’m waiting for your new article, so.
However I know the connect a potetiometer to arduino is not cool, infact the interesting thing, for me, is the java code.
Yes I know, so have a look at this:
http://www.youtube.com/watch?v=U6Ih_74hGy8
it’s using processing to show the joystick position.
may i get the java code..
The Byron board looks pretty cool, I’ll have to keep that one in mind.
Erm, right, take apart a $10 joypad, connect parts to a $20 arduino and have a dinky joypad.