Pi Pico Mouse Jiggler
Requirements
- Raspberry Pi Pico
- Micro USB Male to USB A male cable
- Circuit Python
- Thonny Application
Setup
Install Thonny Onto Workstation
sudo apt install thonny -y
Install Circuit Python Onto Raspberry Pi Pico
- Download Circuit Python U2F file from https://circuitpython.org/board/raspberry_pi_pico/
- Hold down the Boot Sel button on the Raspberry Pi Pico and plug it into the workstation
- Release the Boot Sel button
- Drag and Drop the U2F file into the Raspberry Pi Pico Storage (The Raspberry Pi will reboot)
Setup the Thonny Environment
- Open Thonny
- Tools>Options>Interpreter>Circuit Python Generic>OK
Install HID Library via Thonny
- Tools>Manage Plugins>Manage Packages>Search: adafruit_hid
- adafruit-circuitpython-hid>Install
If you get an error like
Installing to temp directory Error installing 'adafruit-circuitpython-hid': b'403' Installing to: /tmp/tmpz8124mnw/ micropip returned with error code 1
Try the manual method
Install HID Library Manually
- Download https://github.com/adafruit/Adafruit_CircuitPython_HID/archive/refs/heads/main.zip
- extract: /Adafruit_CircuitPython_HID-main/adafruit_hid/
- copy above folder “adafruit_hid”
- into: /media/username/CIRCUITPY/lib/
Write the Code
from adafruit_hid.mouse import Mouse
import board
import digitalio
import time
import usb_hid
mouse = Mouse(usb_hid.devices)
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
led.value = False
time.sleep(5)
while True:
led.value = True
mouse.move(x=2)
led.value = False
time.sleep(0.5)
led.value = True
mouse.move(x=-3)
led.value = False
time.sleep(0.5)
File>Save /code.py
Overwrite?: Do you want to overwrite ‘code.py’ ?
[Yes]
Disabling Storage Device
By default when you plug in the CircuitPython Pi Pico it mounts as a USB mass storage device called CIRCUITPY.
This can be undesirable. As of CircuitPyton 7 boot.py is now supported.
https://learn.adafruit.com/customizing-usb-devices-in-circuitpython
Related
Links
- https://www.raspberrypi.org/products/raspberry-pi-pico/