我正在尝试用我的树莓派 pi4 与树莓派 pico 通信。我的操作系统是 Ubuntu server 20.04 for Raspberry pi。
当我运行下面的代码时,LED 会亮起,当我按下停止时它会关闭,但它会不断抛出下面的错误。
如果您知道解决方案,请告诉我。
我的代码:
from machine import Pin, Timer
led = Pin(25, Pin.OUT)
tim = Timer()
def tick(timer):
global led
led.toggle()
tim.init(freq=2.5, mode=Timer.PERIODIC, callback=tick)
错误:
NameError: name 'led' isn't defined
Traceback (most recent call last):
File "<stdin>", line 7, in tick
NameError: name 'led' isn't defined
Traceback (most recent call last):
File "<stdin>", line 7, in tick
NameError: name 'led' isn't defined
Could not enter REPL. Trying again with 1 second waiting time...
Could not enter REPL. Trying again with 3 second waiting time...
Could not enter REPL. Trying again with 5 second waiting time...
Could not enter REPL. Giving up. Read bytes:
Your options:
- check connection properties;
- make sure the device has suitable firmware;
- make sure the device is not in bootloader mode;
- reset the device and try again;
- try other serial clients (Putty, TeraTerm, screen, ...);
- ask for help in Thonny's forum or issue tracker.
Backend terminated or disconnected. Use 'Stop/Restart' to restart.