Because it's analog, You will need two analog reading through pins with your microcontroller to determine X and Y. Getting an extra electronic enter will Enable you to go through the switch. This code reads the analog values from the joystick's X and Y pins, converts them into corresponding voltage https://jamesi382bys2.wikiconversation.com/user