如何使用Raspberry Pi Pico从计算机读取数据?
我如何使用催眠术从计算机中读取数据到Raspberry Pi Pico?
How do I read data from my computer to Raspberry Pi Pico using MicroPython with pyserial?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了这个问题,从这个 link 。要读取来自USB端口的数据,请使用“ sys.stdin.buffer.read(8)”。
这是一个简短的代码,您可以上传到PICO进行此操作。
使用此代码,它将等到8个字节进来,直到那时它将闲置。我敢肯定,还有一种方法,只是还没有尝试过。
我使用Arduino IDE串行显示器发送数据。将此代码上传到Thonny中(将其保存为Main.py,以便在电源上启动),然后断开PICO,将其插入并打开Arduino串行显示器。发送类似“ 12345678”之类的东西,它应该吐回去。
编辑:
上面的代码将空闲,直到您发送数据为止。要使PICO继续运行,如果未发送数据,请使用以下( source ):
您可以使用thonny发送数据,您不需要Arduino IDE。
I also had this issue and from this link I was able to figure it out. To read data from the usb port use "sys.stdin.buffer.read(8)".
Here is a short code that you can upload to the pico to do this.
With this code it will wait until 8 bytes come in, until then it will idle. I'm sure there is a way around it, just haven't tried yet.
I used the Arduino IDE serial monitor to send data. Upload this code in Thonny (save it as main.py so it starts on power up), then disconnect the pico, plug it back in, and open the Arduino serial monitor. Send something like '12345678' and it should spit it back out.
EDIT:
The above code will idle until you send it data. To have the pico continue running if no data is sent, use the following (source):
And you can just use Thonny to send the data, you don't need the Arduino IDE.