Skip to content

jozefcipa/usb-button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

USB Button (RPi Pico)

Firmware for a Raspberry Pi Pico with a physical button: short / double / long press are sent to the host as raw HID reports (consumer report ID 3 with a 16-bit event code). An LED on GPIO 15 blinks until the host signals ready, then follows host commands. You can customize the report payload and, with a TinyGo override, VID/PID and report format.

The repo is split into firmware/ (TinyGo, for the Pico) and host/ (regular Go, for the listener on your computer).

Quick start

  • Hardware: Button on GPIO 14, LED on GPIO 15 (see firmware/internal/button and firmware/internal/led).
  • Build & flash firmware:
    make build-fw && make flash
  • Host: Build and run the listener (standard Go, not TinyGo):
    • make build-host then ./.bin/hid_listener
    • Use -list to list HID devices. Reports are 3 bytes: [0x03, event_lo, event_hi].

Documentation

Troubleshooting

macOS: "Failed to connect to the device" (HID open failed)

  1. System Settings → Privacy & Security → Input Monitoring
    Add Terminal (or Cursor / your IDE), enable it, then quit and reopen the app.
  2. If it still fails, run the listener with sudo (macOS sometimes requires root for HID):
    sudo ./.bin/hid_listener
  3. Unplug the Pico, plug it back in, then run again.

About

RPi Pico <> Host communication via USB HID

Topics

Resources

Stars

Watchers

Forks

Contributors