如何获得Raspberry Pi Pico与PC /外部设备进行通信?
例如,当我给代码5时,我想打开RPI PICO中的LED(通过电缆连接到PC)。
#This code will run in my computer (test.py)
x=int(input("Number?"))
if (x==5):
#turn on raspberry pi pico led
RPI PICO的代码:
#This code will run in my rpi pico (pico.py)
from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1)
反之亦然(在计算机上使用RPI PICO中的代码执行某些操作)。
如何在RPI PICO中调用/获取PC中的变量?
注意:我正在用OpenCV Python编写代码,我想从计算机上的计算机相机处理数据。我希望RPI PICO根据处理后的数据做出反应。
For example when I give 5 to the code, I want to turn on the LED in our RPi pico (connected to a PC via a cable).
#This code will run in my computer (test.py)
x=int(input("Number?"))
if (x==5):
#turn on raspberry pi pico led
The code of the RPi pico:
#This code will run in my rpi pico (pico.py)
from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1)
Or vice versa (doing something in the code on the computer with the code in the RPi pico).
How can I call/get a variable in the PC to the RPi pico?
Note: I am writing code with OpenCV Python and I want to process the data from my computer's camera on my computer. I want the RPi pico to react according to the processed data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主机和PICO之间通信的一种简单方法是使用串行端口。我有一个 rp2040-Zero ,它以
/dev/dev/dev呈现给主机/ttyacm0
。如果我在RP2040上使用类似的代码:那么我可以在主机上运行此操作以闪烁LED:
这显然只是单向通信,但是您当然可以实现一种机制来将信息传递回主机。
A simple method of communicating between the host and the Pico is to use the serial port. I have a rp2040-zero, which presents itself to the host as
/dev/ttyACM0
. If I use code like this on the rp2040:Then I can run this on the host to blink the LED:
This is obviously just one-way communication, but you could of course implement a mechanism for passing information back to the host.