Skip to content

Commit

Permalink
examples: add an example PCF8574 script
Browse files Browse the repository at this point in the history
  • Loading branch information
attie-argentum committed Oct 9, 2020
1 parent 24b4b37 commit 61480b0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/i2c-pcf8574.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
An example of a script that can be used with the run-script mode.
This will read and write the pins of a PCF8574. Once connected, run:
glasgow run-script i2c-pcf8574.py i2c-initiator -V 3.3
"""

# read pin values
p = await iface.read(0x20, 1)
print('I/O pin state: 0b{:08b}'.format(p))

# write pin values
await iface.write(0x20, [ 0x55 ])

# power down the device after use
await device.set_voltage("AB", 0)

0 comments on commit 61480b0

Please sign in to comment.