Re: PCF8574 Example…..
Why yes you do, The device reads the condition of the output pins, Therefore if you were to set all of the pins low, so as to be sinking current, the readback data would be 00000000. If you want to readback say 4 of the pins that are connected as inputs, you would always mask the output byte with the appropriate input pins set to true. say you want the upper 4 bits to be used as inputs and the lower 4 to be used as outputs, you would always send the output byte masked with 1111 in the upper bit positions by ORING it with %11110000 just before sending it to the device. Then when reading the the device you would mask off the output bits by ANDING the returned byte with %11110000. I have used these I/O expanders for years and they word very well.
Dave Purola,
N8NTA
EN82fn
Bookmarks