当前位置: 代码迷 >> 综合 >> micropython-esp8266控制灯
  详细解决方案

micropython-esp8266控制灯

热度:110   发布时间:2023-11-14 08:09:54.0

官网Pin链接
这里测试nodemcu板载led
在这里插入图片描述
其引脚编号为16

from machine import Pin
p0 = Pin(16, Pin.OUT)    # create output pin on GPIO0
p0.off()                # set pin to "off" (low) level

在交互窗口中输入上诉程序,即可点亮板载led

闪烁

from machine import Pin
import time
p0 = Pin(16, Pin.OUT)    # create output pin on GPIO0
while(1):p0.off()                # set pin to "off" (low) leveltime.sleep(1)p0.on()                # set pin to "off" (low) leveltime.sleep(1)

Pin

classmachine.Pin(id, mode=- 1, pull=- 1, *, value, drive, alt)