参考代码:
from machine ieport Pin;
inport time
LED = Pin(2,Pin,OUI)
KEY = Pin(2,Pin,IN)
sta = 0;
def keyscan()
if KEY.value() == 0;
time.sleep_ms(10);
if KEY.value() = 0;
sta = not sta
LED.value(sta)
while not KEV value(); //按键检测是否松开
pass