def setup(self): gpio.setup(self.pin, gpio.IN, gpio.PUD_UP) self.state = gpio.input(self.pin) self.t = task.LoopingCall(self.loop) self.t.start(0.1)