-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add an example PCF8574 script
- Loading branch information
1 parent
24b4b37
commit 61480b0
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |