As it's analog, You will need two analog studying pins on the microcontroller to find out X and Y. Having an extra digital input will Permit you to read the switch. This code reads the analog values from the joystick's X and Y pins, converts them into corresponding voltage values, https://arcade-joystick06159.blogzag.com/81540816/the-fact-about-arcade-joystick-that-no-one-is-suggesting