简体   繁体   English

在没有设备的情况下为 Raspberry Pi Pico W 编写 MicroPython 代码

[英]Write MicroPython code for Raspberry Pi Pico W whithout having a device

I have ordered a Raspberry Pi Pico W which hasn't arrived yet.我订购了尚未到货的 Raspberry Pi Pico W。 Is there a way for me to start writing MicroPython code before the Pico is here?有没有办法让我在 Pico 出现之前开始编写 MicroPython 代码?

I tried Thonny as suggested in the Raspberry Pi Documentation and set it to use the "MicroPython (Raspberry Pi Pico)" interpreter:我按照Raspberry Pi 文档中的建议尝试了 Thonny ,并将其设置为使用“MicroPython (Raspberry Pi Pico)”解释器:

棘手的选择

But that sems to require an actual device, as Thonny keeps saying但这似乎需要一个实际的设备,正如 Thonny 一直说的那样

Device is busy or does not respond.设备正忙或没有响应。 Your options:您的选择:
- wait until it completes current work; - 等到它完成当前工作;
- use Ctrl+C to interrupt current work; - 使用 Ctrl+C 中断当前工作;
- reset the device and try again; - 重置设备并重试;
- check connection properties; - 检查连接属性;
- make sure the device has suitable MicroPython / CircuitPython / firmware; - 确保设备具有合适的 MicroPython / CircuitPython / 固件;
- make sure the device is not in bootloader mode. - 确保设备未处于引导加载程序模式。

Well, of course I can set Thonny to use the "Local Python 3" interpreter instead, but I guess that could result in code which does not necessarily run on a Pi Pico then?好吧,我当然可以将 Thonny 设置为使用“本地 Python 3”解释器,但我想这可能会导致代码不一定在 Pi Pico 上运行?

Update更新

The Pico is here now and I can say that online emulators such as Wokwi do not (fully?) work: Pico 现在就在这里,我可以说像Wokwi这样的在线模拟器不能(完全?)工作:

import machine
led = machine.Pin("LED", machine.Pin.OUT)
led.on()

lead to导致

Traceback (most recent call last):t str to int回溯(最近一次调用):t str 到 int
MicroPython v1.19.1 on 2022-06-18; 2022-06-18 上的 MicroPython v1.19.1; Raspberry Pi Pi树莓派
File "main.py", line 3, in <module>文件“main.py”,第 3 行,在 <module> 中
TypeError: can't converco with RP2040类型错误:无法与 RP2040 转换

Maybe a different version of Micropython?也许是不同版本的 Micropython? Wifi is not available as well, which obviously is a bummer for the Pico W . Wifi 也不可用,这显然对 Pico W来说是个遗憾。

OK, kind of embarrassing: While being focussed on Thonny and how to set it up, I missed online emulators.好吧,有点尴尬:在专注于 Thonny 以及如何设置它的同时,我错过了在线模拟器。 There's ie Wokwi which looks promising. ie Wokwi看起来很有前途。 If there's a drawback and/or I find a better one, I'll update this answer.如果有缺点和/或我找到更好的缺点,我会更新这个答案。

There are some results searching for virtual Raspberry Pi Pico for example raspberry-pi-pico-emulator-keypad-and-led-interface-project .有一些搜索虚拟 Raspberry Pi Pico 的结果,例如raspberry-pi-pico-emulator-keypad-and-led-interface-project

I'm not sure how customizable it is for your own projects, but worth a look.我不确定它对您自己的项目的可定制性如何,但值得一看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM