Skip to content

Commit 5307005

Browse files
attie-argentumwhitequark
authored andcommitted
examples: add an example PCF8574 script
1 parent fd91c13 commit 5307005

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/i2c-pcf8574.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
An example of a script that can be used with the run-script mode.
3+
4+
This will read and write the pins of a PCF8574. Once connected, run:
5+
6+
glasgow run-script i2c-pcf8574.py i2c-initiator -V 3.3
7+
"""
8+
9+
# read pin values
10+
print('I/O pin state: 0b{:08b}'.format((await iface.read(0x20, 1))[0]))
11+
12+
# write pin values
13+
await iface.write(0x20, [ 0x55 ])
14+
15+
# power down the device after use
16+
await device.set_voltage("AB", 0)

0 commit comments

Comments
 (0)