# https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/timer import machine tcounter = 0 p1 = machine.Pin(27) p1.init(p1.OUT) p1.value(1) def tcb(timer): global tcounter if tcounter & 1: p1.value(0) else: p1.value(1) tcounter += 1 if (tcounter % 10000) == 0: print("[tcb] timer: {} counter: {}".format(timer.timernum(), tcounter)) t1 = machine.Timer(2) t1.init(period=20, mode=t1.PERIODIC, callback=tcb)