Joystick =================== .. figure:: /_static/products/ledong-module/static/images/joystick_h.png :width: 55% :align: center Overview -------------------- Features (X,Y) 2-axis analog output, can be used to make remote controllers for controlling the direction, speed, and other interactive works of moving objects. Technical Specifications ------------------------ Operating voltage: VCC 3.3V -5V Module dimensions: 24*48mm Mounting: 2 plastic building block compatible through-holes Data type: Analog sampling value Pin Definition ------------------- ======= =========================== Pin Definition ======= =========================== GND Ground VCC Power A1 X -axis analog sampling value A2 Y -axis analog sampling value ======= =========================== Example Code ------------------- **When using the joystick for up, down, left, right control, the mPython Board OLED display shows the corresponding direction.** .. code-block:: python from mpython import * p0 = MPythonPin(0, PinMode.ANALOG) p1 = MPythonPin(1, PinMode.ANALOG) import time while True: oled.fill(0) oled.DispChar(str('Direction: '), 0, 0, 1) oled.show() if p0.read_analog() < 1000: oled.fill(0) oled.DispChar(str('Direction: Up'), 0, 0, 1) oled.show() time.sleep(0.2) if p1.read_analog() > 2500: oled.fill(0) oled.DispChar(str('Direction: Right'), 0, 0, 1) oled.show() time.sleep(0.2) if p0.read_analog() > 2500: oled.fill(0) oled.DispChar(str('Direction: Down'), 0, 0, 1) oled.show() time.sleep(0.2) if p1.read_analog() < 1000: oled.fill(0) oled.DispChar(str('Direction: Left'), 0, 0, 1) oled.show() time.sleep(0.2) .. figure:: /_static/products/ledong-module/static/examples/joystick.png :width: 100% :align: center