This is a MicroPython port of bamtna's joyslide project which utilizes a Trill Bar as a touch-sensitive input device that is mapped to the axis of a joystick.
- Microcontroller capable of running a machine.USBDevice compatible port of MicroPython (I used a Pi Pico w/rp2040 board)
- Trill Bar sensor
- Vibrating motor like Adafruit 1201 if haptic feedback is desired
- USB Cable
- MicroPython usb-device-hid hid.py library
- MicroPython usb-device init.py and core.py library
- MicroPythonTrill trill.py and touch.py libraries
Bela's Trill Bar case is available here.
Additionally, I've drawn several trim pieces that fit snugly over top to aid in tactile feedback. All models are available on Thingiverse here.
GPIO pins specific to Pi Pico, will change from board to board. If you need to change pins, modify SCL_PIN and SDA_PIN variables in main.py
- Solder wire from GPIO 8 on Pi Pico to SCL pad on Trill Bar
- Solder wire from GPIO 9 on Pi Pico to SCL pad on Trill Bar
- Solder wire from 3v3 on Pi Pico to VCC pad on Trill Bar
- Solder wire from GND on Pi Pico to GND pad on Trill bar
If using haptic feedback motor:
- Solder positive lead to pin 26
- Solder negative lad to GND
A Qwiic cable can also be used for one or both connections if your board supports it.
** If not using haptic feedback, HAPTIC_PRESENCE can be set to False in main.py **
- Download MicroPython libraries listed in Software Requirements
- Install mpremote, ensure it's in PATH to pick up environment var
- Open a terminal
- Copy relevant main.py, joystick.py, and the USB libraries (making sure to preserve file structure)
mpremote cp main.py :main.pympremote cp joystick.py :joystick.pympremote mkdir usbmpremote mkdir usb\devicempremote cp core.py :\usb\device\core.pympremote cp hid.py :\usb\device\hid.py
- Reset the board with
mpremote soft-reset - (optional) open up gamepad configuration to check if it all worked
mpremote cp __init__.py :\usb\device\__init__.pympremote cp trill.py :trill.pympremote cp touch.py :touch.py
- Reset the board with
mpremote soft-reset - (optional) open up gamepad configuration to check if it all worked
Serial monitor can be used to view logging.
If the device has issues, run trill_print_touch.py with a serial monitor to verify the sensor is working properly.