ESP8266-NodeMCU开发板引脚示意图
LED正极(长脚)接入到D1针脚(也就是GPIO5)
LED负极(短脚)接入到GUN针脚(任意GUN)
LED开关一次MicroPython代码:
from machine import Pin
led=Pin(5)
led=Pin(5,Pin.OUT)
led.on()
led.off()
如果在putty中上面的代码,需要一行一行的粘贴执行。
也可以这样的MicroPython代码:
from machine import Pin
led = Pin(5)
led = Pin(5,Pin.OUT)
led = Pin(5,Pin.OUT,value = 1)
led.value(1)
led.value(0)
两种形式都是可以点亮LED灯的,
LED闪烁MicroPython代码:
from machine import Pin
import time
led=Pin(5)
led=Pin(5,Pin.OUT)
while True:
led.on()
time.sleep(1)
led.off()
time.sleep(1)
代码解释,每间隔秒进行触发命令;