pcf8574 used for input #10380
Unanswered
eichenwind
asked this question in
RP2040 / Pico
Replies: 2 comments 4 replies
-
Looking at the error and the linked docs have you grounded A0, A1 and A2?
What does "I'm able to read them" mean? |
Beta Was this translation helpful? Give feedback.
1 reply
-
It's not clear to me from your question, but your readthedocs link is for a different library than mcauser's one. Does the psolyca/micropython-pcf8574 library not work for you? I've successfully read switch inputs using mcauser's library before |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I looked at the code of https://github.com/mcauser/micropython-pcf8574 and as far as I read the pcf8574 can be used as input or output device. In the code I see that the functions state and direction as described in https://micropython-pcf8574.readthedocs.io/en/latest/pcf8574.html are not used. So I added those functions in the code and I'm able to read them. But it seems that this has no impact to the chip.
so I added in the class:
class PCF8574:
def init(self, i2c, address=0x20):
self._i2c = i2c
self._address = address
self._direction = 0xFF
self_state = 0xFF
self._port = bytearray(1)
if i2c.scan().count(address) == 0:
raise OSError('PCF8574 not found at I2C address {:#x}'.format(address))
This should define all ports as Input ports, seems not to work
If I set direction to 0x0 and state to direction to 0x0, then all ports should be off. Seems also not to work. Does anybody knows where I make a mistake?
Beta Was this translation helpful? Give feedback.
All reactions