Analog Joystick (37 Sensors kit) Description
A joystick made from two potentiometers at right angles to each other. Analog output in both x and y directions. Push knob down for momentary switch. Knob included with the module.
Also called: joystick, mini dual axis joystick, KY023.
Found in kits: 37 sensors, 45 sensors.

Analog Joystick Specification/Notes:
Voltage: 3.3V to 5.0V (No active components with voltage limits, so using other voltages are possible.)
LED: none
X Potentiometer: 10 k ohm, return-to-center (a few are 5 k ohm)
Y Potentiometer: 10 k ohm, return-to-center (a few are 5 k ohm)
Z switch: momentary SPST, pulled to +Voltage on some modules. Active low. Tactile.
Main component datasheet: 252_Series
Size: 25mm X 35mm
There are a number of different sources for these modules. Not every module that looks similar to the ones here behaves exactly the same. Check the specific module that you have for differences in function, voltage levels, pinout, and inactive/active states. Some modules have been found to have incorrectly labeled pins and even poorly soldered components.
Button press (Z switch) is a bit difficult to do without making a substantial change to the X and Y values with the pots centered, and impossible with the pots in some positions. Joystick X and Y output should be close to half of the supply voltage when the joystick handle is centered (at rest).
The unpopulated R5 on the module tested would be the location for the pull-up resistor for the button. If needed, this can be populated with a 10kohm 0805 SMT resistor.

Analog Joystick Module Pin-out:
Typical/common pinout. Always check the pinout for the module that you have.
Analog Joystick Test setup with CGMICROKIT1
To demonstrate how this works, a test setup that uses the CircuitGizmos CGMICROKIT1 (credit to Robert Severson) will be used. The CGMICROKIT1 has a microcontroller that connects to a PC via a USB/serial interface and runs an easy-to-understand yet powerful interpreted BASIC language (credit to Geoff Graham).

But this isn’t your 1980’s BASIC. This is a fantastic implementation of BASIC. No line numbers, made for easy understanding, and advanced microcontroller features.
This setup combines a CGMICROKIT1 with a single solderless breadboard, a USB/serial interface to the PC, and a suitable power supply for a convenient test bed for proving out small circuitry and experimenting with these 37+ sensors.
On the PC a program called MMEDIT (credit to Jim Hiley) helps to make development easier by providing a platform for editing and downloading the code used for these examples. This development environment is simple, powerful, and flexible. Alternate interfaces on the PC are any serial terminal application, including GFXterm. GFXterm (credit to Robert Rozee)
For more information about this test setup please see the information about the setup here: http://circuitgizmos.com/documentation/hardware-datasheets/cgmicrokit1-technical-information/cgmicrokit1-test-setup/
The hardware for the test setup is mounted on a small wooden base. The tested devices are added to this test setup with jumper wires.
Analog Joystick Test 1
Read of analog joystick with CGMICROKIT1, console display. This test uses two analog inputs to read the X and Y values, and a digital input to read the switch input every 200 milliseconds. The values for all three are printed out on the console.
Analog Joystick Test 1 Wiring

- Black wire – Common ground
CGMICRIKIT GND ⇔ Module Ground - Red wire – Supply voltage
CGMICRIKIT 3.3V ⇔ Module +Voltage - Blue wire – Variable resistance X direction
CGMICRIKIT uM4 (analog input) ⇔ Module X - Green wire – Variable resistance Y direction
CGMICRIKIT uM5 (analog input) ⇔ Module Y - Yellow wire – Joystick press switch
CGMICRIKIT uM6 (digital input) ⇔ Module Switch
Analog Joystick Test 1 Code
1 2 3 4 5 6 7 8 9 10 11 |
SETPIN 6, DIN, PULLUP SETPIN 4, AIN SETPIN 5, AIN DO PAUSE 200 S = PIN(6) X = PIN(4) Y = PIN(5) PRINT S, X, Y LOOP |
Analog Joystick Test 1 Operation
Line 1-3: Set pin 6 to digital input with an internal pull-up resistor. Set pins 4 and 5 to analog input.
Line 5 and 11: Loop forever.
Line 6: Pause for 200 milliseconds.
Line 7: Read the switch input.
Line 8 and 9: Read the X and Y voltage values.
Line 10: Print the three values.
Analog Joystick Test 1 Output/Results

The output shows about 4 seconds of button pushing, X, and Y values.
Analog Joystick Test setup with Sensor.Engine: MICRO (S.E:MICRO)
Analog Joystick Test 2
Read of analog joystick with Sensor.Engine:MICRO, console display. Test 1 was performed with a CGMICROKIT1. The same test can be performed with a Sensor.Engine: MICRO. Wiring described in Test 3.
Analog Joystick Test 3
Read of analog joystick with Sensor.Engine:MICRO, draw on display. This test uses two analog inputs to read the X and Y values displays the joystick position on the S.E:Micro display. Joystick switch press clears the display.
Analog Joystick Test 3 Wiring

- Black wire – Common ground
Sensor.Engine:MICRO GND ⇔ Module Ground - Red wire – Supply voltage
Sensor.Engine:MICRO 3.3V ⇔ Module +Voltage - Blue wire – Variable resistance X direction
Sensor.Engine:MICRO P4 (analog input) ⇔ Module X - Green wire – Variable resistance Y direction
Sensor.Engine:MICRO P5 (analog input) ⇔ Module Y - Yellow wire – Joystick press switch
Sensor.Engine:MICRO P6 (digital input) ⇔ Module Switch
Analog Joystick Test 3 Code
1 2 3 4 5 6 7 8 9 10 11 |
SETPIN 6, DIN, PULLUP SETPIN 4, AIN SETPIN 5, AIN CLS DO S = PIN(6) IF S = 0 THEN CLS X = PIN(4) Y = PIN(5) PIXEL X*39, Y*20 LOOP |
Analog Joystick Test 3 Operation
Line 1-3: Set pin 6 to digital input with an internal pull-up resistor. Set pins 4 and 5 to analog input.
Line 4: Clear screen initially.
Line 5 and 11: Loop forever.
Line 6: Read the switch input.
Line 7: If switch pressed (0), then clear display.
Line 8 and 9: Read the X and Y voltage values.
Line 10: Scale the values for the 128×64 display and plot the point.
Analog Joystick Test 3 Output/Results
The OLED display immediately displayed a dot in the center of the screen because the joystick was centered in both the X and Y direction. The joystick was moved up and down, then side to side to make the straight lines. Finally, the joystick was moved around randomly in the upper right quadrant.
If you have any additional information on this sensor/device or have comments, please leave a reply below.
Leave a Reply