-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
279 additions
and
175 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
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,35 @@ | ||
# SPDX-FileCopyrightText: 2019 Mike Causer <https://github.com/mcauser> | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
MicroPython PCF8575 Basic example | ||
Toggles pins individually, then all in a single call | ||
""" | ||
|
||
import pcf8575 | ||
from machine import I2C | ||
|
||
# TinyPICO (ESP32) | ||
i2c = I2C(0) | ||
|
||
pcf = pcf8575.PCF8575(i2c, 0x20) | ||
|
||
# read pin 2 | ||
pcf.pin(2) | ||
|
||
# set pin 3 HIGH | ||
pcf.pin(3, 1) | ||
|
||
# set pin 4 LOW | ||
pcf.pin(4, 0) | ||
|
||
# toggle pin 5 | ||
pcf.toggle(5) | ||
|
||
# set all pins at once with 16-bit int | ||
pcf.port = 0xFF00 | ||
|
||
# read all pins at once as 16-bit int | ||
print(pcf.port) | ||
# returns 65280 (0xFF00) |
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
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
# SPDX-FileCopyrightText: 2019 Mike Causer <https://github.com/mcauser> | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
MicroPython PCF8575 LEDs sinking current example | ||
Connect a LED between P01 and 3V3, via a current limiting resistor. | ||
* LED positive anode (long leg) connected to 3V3. | ||
* LED negative cathode (short leg) connected to P01. | ||
Driving a pin LOW will illuminate the LED. | ||
eg. for a red or blue LED, use a 330K and green LED 220K current limiting resistor. | ||
""" | ||
|
||
import pcf8575 | ||
from machine import I2C | ||
|
||
# TinyPICO (ESP32) | ||
i2c = I2C(0) | ||
|
||
pcf = pcf8575.PCF8575(i2c, 0x20) | ||
|
||
# set P01 LOW and all other pins HIGH | ||
# turn LED on | ||
pcf.port = 0xFFFE | ||
|
||
# turn LED off | ||
pcf.port = 0xFFFF |
Oops, something went wrong.