from machine import Timer
import time
from Maix import GPIO
from fpioa_manager import fm
fm.register(0, fm.fpioa.GPIO0, force=True)
fm.register(17, fm.fpioa.GPIO1, force=True)
led1 = GPIO(GPIO.GPIO0, GPIO.OUT)
led2 = GPIO(GPIO.GPIO1, GPIO.OUT)
status=1
def on_timer(timer):
global status
status = 0 if (status == 1) else 1
#print("time up:",timer)
#print(status)
#print(~status)
led1.value(status)
#print("param:",timer.callback_arg()) MODE_PERIODIC MODE_ONE_SHOT
tim = Timer(Timer.TIMER0, Timer.CHANNEL0, mode=Timer.MODE_PERIODIC, period=1000, callback=on_timer, arg=on_timer)
# tim = Timer(Timer.TIMER0, Timer.CHANNEL0, mode=Timer.MODE_PERIODIC, period=1, unit=Timer.UNIT_S, callback=on_timer, arg=on_timer, start=False, priority=1, div=0)
#print("period:",tim.period())
tim.start()
while(True):
print("wait tim")
time.sleep(5)
#tim.start()
#time.sleep(5)
#tim.stop()
#time.sleep(5)
#tim.restart()
#time.sleep(5)
#tim.stop()
#del tim
K210定时器实例3
猜你喜欢
转载自blog.csdn.net/lmf666/article/details/110879657
今日推荐
周排行