PCF8574 has a little habit at input.
To enable both input and output of SPI, use MCP23017.
(In case of output only, there is no problem with using PCF8574)
Details
PCF8574 has only one register for data input / output.
There is a register for pin mode and direction in MCP23017.
Therefore, by using MCP23017, various input and output can be made.
IOExpander library (github)
I prepared a library.
I made this library to access SPI SRAM. The speed is a bit slow. Depending on usage, it would be very useful.
It is possible to access the SPI using either PCF8574 or MCP23017.
Also when you do not use SPI.
I2C Expander pins can be accessed with familiar instructions such as pinMode, digitalWrite, digitalRead.
Two examples are included.
For which device you use, set it with #define in IOExpander.h.
There are 16 I/O pins of the MCP23017. PA0 to PA7, and PB0 to PB7. In my library access PA0 as 0 and PB7 as 15 with consecutive numbers.
ex) If you want to use PB0, the pin number will be 8.