I'm having trouble with the Timer.Alarm() functions. Shouldn't the following code print "Hello" every 5 seconds repeatedly?
Timer.Alarm(print ('Hello'), 5, periodic=True)
In the REPL, it doesn't ever repeat.
@robert-hh Got it! Many thanks!
robert-hh last edited by
@jmpratt No. You have to define a callback function yourself. Using a lambda function works for me:
from machine import Timer Timer.Alarm(lambda x: print("hello"), 5, periodic=True)
Note that since the callback gets an argument, the lambda function must define one, even if it is discarded.