连线如下


代码如下
# 导入time模块
import time
# 导入Pin模块
from machine import Pin
pin_2 = Pin(2, Pin.OUT) # 构建led1对象,GPIO15输出
# 永真循环
while True:
# 使IO15输出高电平,点亮LED
pin_2.on()
# 延时0.5秒
time.sleep(0.5)
# 使IO15输出低电平,熄灭LED
pin_2.off()
time.sleep(0.5)
