summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/machine_pinbase.py
blob: 4c467c2d26e678a1983c2f3b8fca8da0176c1c86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
try:
    import machine

    machine.PinBase
except:
    print("SKIP")
    raise SystemExit


class MyPin(machine.PinBase):
    def __init__(self):
        print("__init__")
        self.v = False

    def value(self, v=None):
        print("value:", v)
        if v is None:
            self.v = not self.v
            return int(self.v)


p = MyPin()

print(p.value())
print(p.value())
print(p.value())
p.value(1)
p.value(0)