Archive for May 10th, 2017
A bag of sub-one-dollar resistive joysticks arrived from halfway around the planet:
A quick-and-dirty test routine showed the sticks start out close to VCC/2:
Welcome to minicom 2.7 OPTIONS: I18n Compiled on Feb 7 2016, 13:37:27. Port /dev/ttyACM0, 10:23:45 Press CTRL-A Z for help on special keys Joystick exercise Ed Nisley - KE4ZNU - May 2017 00524 - 00513 - 1
minicom on the serial port, as the Arduino IDE’s built-in serial monitor ignores bare Carriage Return characters.
The joystick hat tilts ±25° from its spring-loaded center position, but the active region seems to cover only 15° of that arc, with a 5° dead zone around the center and 5° of overtravel at the limits. This is not a high-resolution instrument intended for fine motor control operations.
The analog input values range from 0x000 to 0x3FF across the active region. Aim the connector at your tummy to make the axes work the way you’d expect: left / down = minimum, right / up = maximum.
delay(100) statements may or may not be needed for good analog input values, depending on some imponderables that seem not to apply for this lashup, but they pace the
loop() to a reasonable update rate.
Pushing the hat toward the PCB activates the simple switch you can see in the picture. It requires an external pullup resistor (hence the
INPUT_PULLUP configuration) and reports low = 0 when pressed.
Those are 0.125 inch (exactly!) holes on a 19.5×26.25 mm grid in a 26.5×34.25 mm PCB. Makes no sense to me, either.
The trivial Arduino source code as a GitHub Gist: