Joystick (2 axis + button) — initialization (joystick_init)¶
What it does: Initializes a two-axis analog joystick (VRX, VRY) with a SW button and sets the orientation of the axes according to the selected rotation.

Inputs¶
X axis: X axis analog pin.Y axis: Y axis analog pin.switch: joystick button pin.- Field
joy_name: joystick identifier. - Field
rot: axis rotation (0°,90°,180°,270°).
Output¶
- None (statement block).
When to use it¶
- Once at program start before reading axis and direction.
- When you use a physical joystick connected to the CPU pins. For a Bluetooth virtual joystick, this block is not necessary.
Tips and pitfalls¶
- For ESP32C3, the maximum measurable voltage on the AD converter is 2.5V. To use the joystick, it is necessary to reduce the output voltage, for example by connecting a 2Kohm resistor in series in front of the VCC pin of the joystick.

- A regular joystick module consists of two 10K potentiometers and a button.
- After a mechanical release, the center may not be exactly 0, so the center position is automatically calibrated when initialization is called.
- In this implementation, the axis is used in the range -100% to 100%.
Usage example¶

Generated Python example¶
import joy_lib
joystick1 = joy_lib.joystick(34, 35, 32, 0)