timer_tests.py

# Questo lavoro è concesso in licenza MIT.
# Copyright (c) 2013-2023 OpenMV LLC. Tutti i diritti riservati.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Esempio di test timer
#
# Questo esempio testa tutti i timer.

import time
from pyb import LED
from pyb import Timer

blue_led = LED(3)


# Nota: le funzioni che allocano memoria non sono consentite nei callback
def tick(timer):
    blue_led.toggle()


print("")
for i in range(1, 18):
    try:
        print("Testing TIM%d... " % (i), end="")
        tim = Timer(i, freq=10)  # crea un oggetto timer usando il timer 4 - trigger a 1Hz
        tim.callback(tick)  # imposta il callback sulla nostra funzione tick
        time.sleep_ms(1000)
        tim.deinit()
    except ValueError as e:
        print(e)
        continue
    print("done!")

results matching ""

    No results matching ""