mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add timer callback example.
This commit is contained in:
parent
b0f4ebf0cd
commit
34ee346846
15
usr/examples/02-Board-Control/timer_control.py
Normal file
15
usr/examples/02-Board-Control/timer_control.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Timer Control Example
|
||||||
|
#
|
||||||
|
# This example shows how to use a timer for callbacks.
|
||||||
|
|
||||||
|
import time
|
||||||
|
from pyb import Pin, Timer
|
||||||
|
|
||||||
|
def tick(timer): # we will receive the timer object when being called
|
||||||
|
print("Timer callback")
|
||||||
|
|
||||||
|
tim = Timer(4, freq=1) # create a timer object using timer 4 - trigger at 1Hz
|
||||||
|
tim.callback(tick) # set the callback to our tick function
|
||||||
|
|
||||||
|
while (True):
|
||||||
|
time.sleep(1000)
|
||||||
Loading…
Reference in New Issue
Block a user