I keep coming up with so many improvements to my interface design (I'm up to version 6 now) that I'm not getting much built. I decided that I had to make the pins for the SPI and I2C buses available. But that means using five GPIO pins that I had other plans for. I have to have at least eight inputs to handle the motion detectors and door sensors for the alarm system. At least four relay outputs would be nice too, so the Raspberry Pi is quickly running out of GPIO pins.
This diagram shows how this needs to be connected. GPIO pins 1, 2, and 3 are set to output mode and used as address lines to select which input to read. GPIO pin 0 is set to input mode and connected to the output of the multiplexer.
(Note: I always refer to WiringPi pin numbers, not the standard BCM numbering.)
The result is that the interface can still have 8 inputs, but only use 4 GPIO pins to do it.
I will probably do the same thing (in reverse) to allow two GPIO pins to provide four select lines for the SPI bus. It may be a while until I do that since the SPI bus is for future expansion. I don't have any devices for it yet, just ideas.