Extending the Raspberry Pi GPIO with an I/O expander

As we have seen, making use of the higher-level bus protocols allows us to connect to more complex hardware quickly and easily. The I2C can be put to great use by using it to expand the available I/O on the Raspberry Pi, as well as providing additional circuit protection (and, in some cases, additional power to drive more hardware).

There are lots of devices available that provide I/O expansion over the I2C bus (and also SPI), but the most commonly used is a 28-pin device, MCP23017, which provides 16 additional digital input/output pins. Being an I2C device, it only requires the two signals (SCL and SDA connections, plus ground, and power) and will happily function with other I2C devices ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.