01
Introduction
The XY joystick sensor, also known as a dual-axis button joystick sensor, is made using a PS2 joystick potentiometer. It features 2-axis analog output (X, Y) and 1 digital output for the button. It is used in scenarios such as smart car/robot control.
02
Principle
The dual-axis button joystick mainly consists of two sliding potentiometers and a button. When the joystick is moved, the resistance of the sliding potentiometers changes, which in turn alters the corresponding X/Y voltage values. Pressing the joystick down will trigger the button, causing the corresponding SW signal to go low.
Wiring
- GND: Power negative, connect to GND
- +5V: Power positive, connect to 3.3V
- VRx: X-axis signal, connect to P0
- VRy: Y-axis signal, connect to P1
- SW: Button signal, connect to P2
Program
Program Explanation: When powered on, the serial output is redirected to USB for easy data observation. Data is read from the P0, P1, and P2 interfaces and assigned to the variables x, y, and is_pressed respectively. These three variables are then combined into an array and written to the serial output. Run the program, and by manipulating the joystick, you can observe the corresponding value changes..





