Interfacing with an analog joystick

posted Feb 6th 2010 12:10pm by
filed under: peripherals hacks

[Firestorm_x1] put together a tutorial about interfacing an analog joystick with a microcontroller. These analog sticks are easy to find; he got his from Goodwill but we’ve got a couple in our junk box right now. The stick uses variable resistors to report its position so it’s just a matter of reading and interpreting that data. After explaining the concepts he demonstrates how to use the joystick to control a Basic Stamp 2 based robot, the Boe-Bot. This could easily be adapted for use with other robot platforms.



12 Responses to Interfacing with an analog joystick

  • Fridolin says:

    Nice Writeup, but common/old and not really a Hack…

  • dooglehead says:

    I did something that is somewhat similar to this. I hooked up an Atari 2600 controller to a Basic Stamp 2, and hooked that up to a computer so I could use it as a computer controller.

  • Osgeld says:

    yea its common, but I haven’t seen this good of a write up ever, usually your lucky to get a text file with some pin-outs and kinda have to kludge the conversion together in your brain

  • CJ says:

    I made a dick out of this with a vibrator from a PS2 Controller…. mine was purple. I am being honest.

    http://img53.imageshack.us/img53/3633/cam0244fg9.jpg

    LOL

  • cynic says:

    This won’t work for most microsoft sidewinder products though, as they used a digital-over-analog protocol. A very nice chap over on the descent forums has a mostly open black-box that decodes the data from the joysticks and has a USB interface. It’s an OLD project, but the last update seems to have been in November. (Search for the words “project archive”, the text’s tiny)
    http://grendel.koolbear.com/3dpro.htm

    A slightly wasteful newer version using the Teensy microcontroller is here:
    http://www.descentbb.net/viewtopic.php?t=15526

    Should I submit something like this?

  • Brandonman says:

    I’ve seriously considered making a Dr. Evil like chair with the joystick and everything for rotation… this could be a gold-mine ;P

  • Mike D. says:

    Nice documentation and tutorial. The Stamp lives on!

  • macegr says:

    When I use old analog joysticks I always pop them open and solder the 5V line (it’s already present) to the other side of the potentiometers. That converts the rheostat-type output to voltage-divider output. Then just use ADC inputs, no need to mess around with external capacitors, calibration, or low-functionality threshold based detection (or topheavy exponential calculations).

  • Rupin says:

    A shortcoming-Most joysticks today employ USB, rather than the gameport.Most laptops and newer motherboards have completely removed support for the game port.
    A USB version of this same would be way cooler.

  • octel says:

    @Rupin
    I don’t think a Basic Stamp can handle USB comms…

  • Coligny says:

    Rupin, check out leo bodnar card BU0836X

    http://www.leobodnar.com/

    It’s like, totally better than sliced bread…

  • Leave a Reply

    XHTML: You can use these tags: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Hack a Day serves up fresh hacks each day, every day from around the web as well as hacking related news.

    Send us your hacks






         




    Hacks

    Resources