Gtimer - Use the periodic GTimer


  • AmebaD [ AMB23 / AMB21 / AMB22 / BW16 / BW16-TypeC ] x 1


There are 3 sets of general timers available to user, each at 32KHz, they are timer 1/2/3.
Here we use timer 1 as example to demonstrate how a periodical timer works.


Copy and paste the first 3 lines of code into REPL to see its effect.

from machine import Timer
t = Timer(1)  # Use Timer 1/2/3 only
t.init(t.PERIODIC, 2000)  # Set GTimer fired periodically at duration of 2 seconds, printing text on the terminal

# To stop the periodical timer, type
Please confirm that QQ communication software is installed