{
  "id": "howmanyoliversarethere/micropython-joystick-2-unit",
  "name": "micropython-joystick-2-unit",
  "prettyName": "micropython-joystick-2-unit",
  "description": "A MicroPython driver for the M5Stack Joystick 2 Unit",
  "version": "",
  "author": "howmanyoliversarethere",
  "license": "MIT",
  "tags": [],
  "status": "VALID",
  "official": false,
  "source": "https://github.com/howmanyoliversarethere/micropython-joystick-2-unit",
  "updatedAt": "2026-09-27T07:00:16.395Z",
  "page": "https://checkmim.com/packages/howmanyoliversarethere+micropython-joystick-2-unit",
  "createdAt": "2025-05-27T04:29:46.329Z",
  "submittedBy": "oliverr",
  "install": {
    "mpremote": "mpremote mip install github:howmanyoliversarethere/micropython-joystick-2-unit",
    "mip": "import mip; mip.install(\"github:howmanyoliversarethere/micropython-joystick-2-unit\")"
  },
  "readme": "# MicroPython Joystick 2 Unit\n\nThis repository houses a [MicroPython](https://micropython.org) driver for the M5Stack [Joystick 2 Unit](https://docs.m5stack.com/en/unit/Unit-JoyStick2).\n\nIt allows you to:\n\n- Read the current X and Y values of the joystick\n    - Either integer (0 - 65535) or float (0.0 - 1.0)\n- Read whether the button is pressed or not\n- Control the inbuilt RGB LED\n- Read the value of the inbuilt RGB LED\n- Read the Bootloader and Firmware version of the device\n\nhttps://github.com/user-attachments/assets/ebfabfb1-8d36-41e5-93a6-b1bf625ae02b\n\n## Usage\n\nBelow is a minimal example of setting up the peripheral and then reading values from it.\n\n```python\nfrom machine import SoftI2C, Pin\nimport joystick_2_unit\n\ni2c = SoftI2C(scl=Pin(32), sda=Pin(26))  # Pins for the ATOM Lite Grove port\njoystick = joystick_2_unit.Joystick2Unit(i2c)\njoystick.set_led(253, 176, 192)\nprint(\n    f\"x: {joystick.get_x()}, y: {joystick.get_y()},\"\n    f\" button: {joystick.is_pressed()}, led: {joystick.get_led()}\"\n)\n```\n\nSee the `examples` folder for example code demonstrating all of the capabilities of the device. To run these, first modify `examples/config.py` to match the pins used for your board, and then you can use `mpremote` to mount and run the code. Eg:\n\n```bash\nmpremote mount .\nfrom examples import print_status\n```\n\n## Installation\n\nThe easiest way to install the package is using [mip](https://docs.micropython.org/en/latest/reference/packages.html#installing-packages-with-mip) via [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html):\n\n```bash\nmpremote mip install github:HowManyOliversAreThere/micropython-joystick-2-unit\n```\n\nAlternatively just grab `joystick_2_unit.py` and load it however you like.\n"
}