timer_control.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 controllo timer
#
# Questo esempio mostra come usare un timer per i callback.

import time
from pyb import LED
from pyb import Timer

blue_led = LED(3)


# riceveremo l'oggetto timer quando verremo chiamati
# Nota: le funzioni che allocano memoria non sono consentite nei callback
def tick(timer):
    blue_led.toggle()


tim = Timer(2, freq=1)  # crea un oggetto timer usando il timer 2 - trigger a 1Hz
tim.callback(tick)  # imposta il callback sulla nostra funzione tick

while True:
    time.sleep_ms(1000)

results matching ""

    No results matching ""