I have a project that already makes use of the components from Unclerus, including the hd44780 for driving an LCD display.
I need to expand my Gpio ports so I've added a discrete pcf8574 board in. Now I already have the includes in my project as it's part of the lcd setup. I can happily read from the new pcf8574 board. Sounds great? Not really.
I seem to only be able to read or write to the pcf8574 as an 8 bit word, effectively using it as an 8 bit parallel port. What I'd like to be able to do is read each pin individually at any point, but they don't seem to be addressable.
Any help? Many thanks. Link to the unclerus lib below.
https://github.com/UncleRus/esp-idf-lib ... ts/pcf8574
Reading Pcf8574 as pins rather than 8 bit word
-
- Posts: 1734
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Reading Pcf8574 as pins rather than 8 bit word
For reads, you'll have to extract the individual pins' states from the 8-bit value 'manually' via bit-wise AND (and possibly right-shifting).What I'd like to be able to do is read each pin individually at any point, but they don't seem to be addressable.
To write individual pins, you'd maintain a copy of the current output state in an 8-bit variable which you modify via bit-wise OR and AND NOT before sending the updated 8-bit value to the IO expander.
Re: Reading Pcf8574 as pins rather than 8 bit word
Thanks @microcontroller, I wasn't sure if there was a different way of interfacing with the pcf8574 or if I just needed to go down that route. Cheers!
Who is online
Users browsing this forum: Baidu [Spider] and 227 guests