[英]Raspberry Pi Pico - problem with Thonny interpreter
I have a trouble with programming Raspberry Pi Pico.我在编写 Raspberry Pi Pico 时遇到了麻烦。 I am using Thonny IDE and micropython.
我正在使用 Thonny IDE 和 micropython。 I am just a beginner so just download code from their website ( https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/6 ) and install it to microcontroller.
我只是一个初学者,所以只需从他们的网站( https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/6 )下载代码并将其安装到微控制器。 But when I save this code:
但是当我保存这段代码时:
from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
while True:
if button.value():
led.toggle()
time.sleep(0.5)
I receive this message:我收到这条消息:
Traceback (most recent call last): File "", line 10 IndentationError: unindent doesn't match any outer indent level Could you help me please? Traceback(最近一次调用最后一次):文件“”,第 10 行 IndentationError:unindent 与任何外部缩进级别都不匹配,您能帮帮我吗?
You need to indent your code properly:您需要正确缩进代码:
from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
while True:
if button.value():
led.toggle()
time.sleep(0.5)
Maybe try this:也许试试这个:
from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
while True:
if button.value():
led.toggle()
time.sleep(0.5)
I just changed if button.value(): four more spaces in so its inside the while true: loop.我刚刚更改了 if button.value(): 四个空格,所以它在 while true: 循环内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.