Code: Select all
from machine import Timer
class TOUCH(object):
def __init__(self,pin):
self.pin = pin
self.tim = Timer(4)
self.tim.init(mode=Timer.PERIODIC, period=2000,callback=self.touch_cb)
def touch_cb(self, tim):
print(self.pin)
def stop(self):
self.tim.deinit()
a = TOUCH("1")
print(a)
dir(a)
b = TOUCH("2")
print(b)
dir(b)
while 1:
pass
and send the status via websocket.