The I/O expander described in this post provides a total of 24 digital I/O ports as well as 16 analog ports. Each MCP23017 provides 16-bit, general purpose parallel I/O expansion for I2C bus or SPI applications. The 74HC4051 is a 8-channel analog multiplexer/ demultiplexer. The PCB includes 2x MCP23017 and 2x 74HC4051.
The Arduino sketch is based on the wire library and the MCP23017 library from Adafruit. In this application the Analog In pins A0 and A1 of the Arduino board are used as inputs for the data from the analog mux/demux. The addresses for the 4051 and the ports are selected by utilizing the GPA port of one of the digital IO expanders MCP23017 and the I2C bus.
For more information, including PCB layout, assembly, schematic and the sketch, follow the link below.