Digital Joystick


If you examine the photo here carefully, you'll note the rugged arcade-style joystick mounted for testing purposes on a piece of scrap wood. It's digital in nature, meaning that it is fabricated around four switches. Pressing the joystick one way or another activates the switches for the cardinal directions: north, south, east and west. And pushing between two consecutive directions activates two adjacent switches simultaneously, yielding the additional settings: NW, NE, SW, SE.

Incidentally, I picked this unit up dirt-cheap as surplus from All Electronics several years ago.

Continuing your scan of the photo, observe the eight LEDs which indicate the eight directions possible. Since only one is lit at a time, a single current limiting resistor is all it takes. Here's the schematic:


I think the source code will startle you; it's amazingly short and to the point! It boils down to little more than complementing the input bit pattern (negative logic, since I'm using pull-up resistors on the joystick switches), squashing the bits together from port lines A.0, A.1, A.6 and A.7, and then looking up the desired LED from an indexed constant array. All very straightforward Pascal!

Click to get the source code.
Click to get the schematic PDF.

Next Project: Rotary Binary Switch

1 comment:

  1. I see that Amazon has all sorts of mini digital joysticks now on convenient breakout boards, at very low cost.

    ReplyDelete