Image may be NSFW.
Clik here to view.
Can I use my PC to send data to a Pi Pico W over USB?
computer.pyAfter the Pi Pico W receives data, it sends a key press to the computer keyboard.
picow.pyCan I achieve this with my current setup? If not, what is another way to make it work?
Thank you for your help!
Clik here to view.

Can I use my PC to send data to a Pi Pico W over USB?
computer.py
Code:
import serialimport timeser = serial.Serial('COM5', 115200)while True: ser.write(b'1\n') time.sleep(1) ser.write(b'2\n') time.sleep(1) ser.write(b'3\n') time.sleep(1)
picow.py
Code:
import timeimport boardimport digitalioimport usb_cdcfrom adafruit_hid.keyboard import Keyboardfrom adafruit_hid.keycode import Keycodeimport usb_hidkeyboard = Keyboard(usb_hid.devices)while True: if usb_cdc.data.connected: if usb_cdc.data.in_waiting > 0: command = usb_cdc.data.read().decode('utf-8').strip() if command == '1': keyboard.send(Keycode.ONE) elif command == '2': keyboard.send(Keycode.TWO) elif command == '3': keyboard.send(Keycode.THREE) time.sleep(0.01)
Thank you for your help!
Statistics: Posted by pp7sec — Thu Jul 25, 2024 10:21 am — Replies 0 — Views 12