本站改版新增arduino频道
from machine import Pin
import time
button = Pin(27, Pin.IN) #将IO27/D4引脚定义为输入
led = Pin(25, Pin.OUT) #将IO25/D2引脚定义为输出
while True:
led.value(button.value()) #获取按钮状态并赋给led引脚
time.sleep(0.1)
实验效果
按键按下时,LED灯亮,未按下时,LED灯灭。
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0096211433410645 seconds