1try:
2    try:
3        import umachine as machine
4    except ImportError:
5        import machine
6    machine.PinBase
7except:
8    print("SKIP")
9    raise SystemExit
10
11
12class MyPin(machine.PinBase):
13    def __init__(self):
14        print("__init__")
15        self.v = False
16
17    def value(self, v=None):
18        print("value:", v)
19        if v is None:
20            self.v = not self.v
21            return int(self.v)
22
23
24p = MyPin()
25
26print(p.value())
27print(p.value())
28print(p.value())
29p.value(1)
30p.value(0)
31