If you have experience with playing games on consoles such as PlayStation or Xbox, you will be familiar with using joystick control to manage game movements and perform various actions. An analog joystick usually consists of two potentiometers. This sensor generates 2D direction points.
There are many cheap analog joystick sensors available in online electronics stores such as AliExpress and Alibaba. One of the analog joystick models is Thumb Joystick from SparkFun, found at the following link: https://www.sparkfun.com/products/9032. You can see this device in figure 3-2:
An analog joystick usually has five pins: VCC, GND, Vx, Vy, and SW. The Vx and Vy pins represent direction values from the device.
Another option is to use a joystick module kit. This is a complete kit that you use directly on your board...