Expanding Microcontroller Pins with an I/O Expander Part 2 (MCP23017)
Introduction
Previously, I used an I/O Expander called MCP23S08, but this time, I tried the MCP23017.
The MCP23017 uses I2C communication and allows you to expand up to 16 pins. It also has three address selection pins, which means you can connect up to eight devices.
The MCP23S08, on the other hand, uses SPI communication and supports up to 8 pins, with two address selection pins.
In other words, with just two I2C communication lines, you can greatly increase the number of available I/O pins.
▼ Akizuki Denshi product page:
16-bit I2C I/O Expander MCP23017 – Akizuki Denshi
If you want to increase the number of pins, adding another microcontroller is also an option, but the MCP23017 is a cheaper and smaller solution.
▼ Previous related article:
Building the Circuit
This time, I used the Seeed Studio XIAO nRF52840 as the microcontroller. It’s the same one I used in the previous article.
▼ Previous article:
If you can expand the number of pins on a small microcontroller, it might be possible to make the overall system even more compact.
One thing to note is that the pins of the MCP23017 cannot supply large currents. According to the datasheet, the maximum seems to be about 25 mA. It’s similar to microcontroller pins, so driving motors directly would be difficult.
▼ Circuit diagram

▼ Actual wiring

Writing the Program
▼ This time, I used the Adafruit library:
Arduino | Adafruit MCP23017 I2C GPIO Expander | Adafruit Learning System
▼ The program is simple—it lights up LEDs in sequence. Since it uses common Arduino functions, it’s easy to write and understand.
▼ Actual operation: Sixteen LEDs light up one after another.
Conclusion
Expanding 16 pins via I2C communication is quite convenient. When using XIAO-series microcontrollers, I often ran out of pins and had to add another board just to drive motors, but this might eliminate that need.
▼ At Akizuki Denshi, there aren’t many I/O Expander options, but other distributors offer surface-mount versions:
https://www.marutsu.co.jp/GoodsListNavi.jsp?path=1900250012



