pin.py 554 Bytes
Newer Older
1
2
from pyb import Pin

3
p = Pin('Y1', Pin.IN)
4
5
6
7
8
print(p)
print(p.name())
print(p.pin())
print(p.port())

9
10
11
p = Pin('Y1', Pin.IN, Pin.PULL_UP)
p = Pin('Y1', Pin.IN, pull=Pin.PULL_UP)
p = Pin('Y1', mode=Pin.IN, pull=Pin.PULL_UP)
Damien George's avatar
Damien George committed
12
print(p)
13
14
15
print(p.value())

p.init(p.IN, p.PULL_DOWN)
Damien George's avatar
Damien George committed
16
17
18
p.init(p.IN, pull=p.PULL_DOWN)
p.init(mode=p.IN, pull=p.PULL_DOWN)
print(p)
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
print(p.value())

p.init(p.OUT_PP)
p.low()
print(p.value())
p.high()
print(p.value())
p.value(0)
print(p.value())
p.value(1)
print(p.value())
p.value(False)
print(p.value())
p.value(True)
print(p.value())