Adafruit-MCP23017-Arduino-Library

This repository provides an Arduino library for the MCP23008/17 I2C and MCP23S08/17 SPI port expanders, enabling users to easily interface with and control these devices using Arduino boards. Pin addressing

370
205

Here's a summary of the README content:

This document describes the Adafruit MCP23017 Arduino Library, designed for interfacing with MCP23008/17 I2C and MCP23S08/17 SPI port expanders. It provides functions for controlling individual pins, such as setting pin direction (pinMode) and reading/writing digital values (digitalRead, digitalWrite). Pin addressing is crucial, with specific IDs assigned to each pin (GPA0-7, GPB0-7) for use in these functions.

For SPI communication, the library supports hardware address pins (A2, A1, A0) for selecting individual devices on the SPI bus. The begin_SPI() function takes the chip select (CS) pin, SPI interface, and hardware address as arguments. Enabling address pin recognition requires calling enableAddrPins(). A hardware bug in the MCP23S17 chip requires setting the hardware address to 0b1XX if A2 is high, even when not using addressing.

A potential I2C bus corruption bug exists if an input pin changes state during I2C readout, but this is rare.

Repository

AD
adafruit

adafruit/Adafruit-MCP23017-Arduino-Library

Created

February 14, 2012

Updated

March 28, 2025

Language

C++

Category

Developer Tools