本站改版新增arduino频道
通过定时器让LED周期性每秒闪烁1次
from machine import Pin,Timer led=Pin(2,Pin.OUT) Counter = 0 Fun_Num = 0 def fun(tim): global Counter Counter = Counter + 1 print(Counter) led.value(Counter%2) #开启RTOS定时器,编号为-1 tim = Timer(-1) tim.init(period=1000, mode=Timer.PERIODIC,callback=fun) #周期为1000ms
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0093481540679932 seconds