Page 1 of 1

Pi Pico Pressure sensor as pen tablet input

Posted: Fri Oct 24, 2025 7:38 pm
by OllieLearnsCode
Hello,

I have a pi pico and a Circular forse sensitive resistor

Code: Select all

from machine import Pin, ADC
import time
fsr_pin = ADC(26)
NOISE = 1000
MAX_RAW_VALUE = 65535
print("FSR started")
def pressure_percentage(raw_adc):
 if raw_adc<NOISE:
 return 0
 
 percentage = (raw_adc - NOISE)/(MAX_RAW_VALUE - NOISE)*100
 return round(percentage, 1)
while True:
 
 raw_value = fsr_pin.read_u16()
 
 print (pressure_percentage(raw_value))
 
 time.sleep(0.2)
This code reads the pressure and it works well. However, I now want windows to recognise this input as a pen tablet pressure. I believe I can do this with the usb_hid module but I get an error that it isn't found. How do i get the usb_hid input working no my pi Pico? thanks

Re: Pi Pico Pressure sensor as pen tablet input

Posted: Sat Oct 25, 2025 10:01 am
by hippy
OllieLearnsCode wrote:
Fri Oct 24, 2025 7:38 pm
I believe I can do this with the usb_hid module but I get an error that it isn't found.
My understanding is the MicroPython USB_HID module is only available for the PyBoard port and not the for the Pico / RP2 port.

CircuitPython, based on MicroPython, does appear to have a usb_hid module which works with Pico / RP2 devices so that's probably the easiest path to take.

Re: Pi Pico Pressure sensor as pen tablet input

Posted: Sat Oct 25, 2025 10:53 am
by Lobo-T
But you do have machine.USBDevice on the RP2.
https://docs.micropython.org/en/latest/ ... evice.html
https://github.com/micropython/micropyt ... usb#readme

AltStyle によって変換されたページ (->オリジナル) /