[RTL8722CSM] [RTL8722DM] Timer - 周期性定时器
材料准备
AmebaD[AMB21 / AMB22] x 1
范例说明
这里有3个定时器可以使用, 全部是32kHz, 分别是定时器1/2/3。我们使用定时器1来示范一个周期性定时器是怎样工作的。
复制下面最初的3行代码至REPL来查看结果。
1from machine import Timer
2t = Timer(1) # Use Timer 1/2/3 only
3t.start(2000000, t.PERIODICAL) # Set GTimer fired periodically at duration of 2 seconds, printing text on the terminal
4# To stop the periodical timer, type
5t.stop()
信息
–timer triggered. to stop: type t.stop()– 每2秒会被打印在端口。如需停止定时器, 输入
t.stop()。