Skip to content

Commit 17e667a

Browse files
committed
timer changed to loboris/MicroPython_ESP32_psRAM_LoBo/wiki/timer
1 parent 7d6309e commit 17e667a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

13.system/timer.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import machine
2+
3+
tcounter = 0
4+
5+
p1 = machine.Pin(18)
6+
p1.init(p1.OUT)
7+
p1.value(1)
8+
9+
def tcb(timer):
10+
global tcounter
11+
if tcounter & 1:
12+
p1.value(0)
13+
else:
14+
p1.value(1)
15+
tcounter += 1
16+
if (tcounter % 10000) == 0:
17+
print("[tcb] timer: {} counter: {}".format(timer.timernum(), tcounter))
18+
19+
t1 = machine.Timer(2)
20+
t1.init(period=20, mode=t1.PERIODIC, callback=tcb)

0 commit comments

Comments
 (0)