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 on the ...

Get Raspberry Pi for Python Programmers Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.