Skip to content
FunCoding

Adafruit-MCP23017-Arduino-Library

Arduino Library for Adafruit MCP23017

Star
385
Category
Other
Last commit
Mar 1, 2024

Adafruit MCP23017 Arduino Library Build StatusDocumentation

This is a library for the MCP23008/17 I2C and MCP23S08/17 SPI Port Expanders.

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Carter Nelson for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution

To install, use the Arduino IDE Library Manager.

Pin Addressing

When using single pin operations such as pinMode(pinId, dir) or digitalRead(pinId) or digitalWrite(pinId, val) then the pins are addressed using the ID's below. For example, for set the mode of GPB0 then use pinMode(8, ...). NOTE The MCP23008 and MCP23S08 only have GPAx pins.

MCP23x08 Pin #MCP23x17 Pin #Pin NamePin ID
1021GPA00
1122GPA11
1223GPA22
1324GPA33
1425GPA44
1526GPA55
1627GPA66
1728GPA77
--1GPB08
--2GPB19
--3GPB210
--4GPB311
--5GPB412
--6GPB513
--7GPB614
--8GPB715

Use of HW address pins for SPI device

Library supports MCP23Sxx HW pin addressing (A2, A1, A0 for S17 and A1, A0 for S08) To use it provide HW address to begin_SPI(CS, SPI, HW_ADDR) function, and as a result each SPI message will contain correct chip address.

Example: mcp.begin_SPI(10, &SPI, 0b101);

HW Address recognition must be enabled by enableAddrPins() function. NOTE Calling enableAddrPins() will enable IOCON.HAEN bit for all active (CS low) devices on SPI bus. NOTE There is hardware bug in the MCP23S17 chip, see "MCP23S17 Rev. A Silicon Errata". As a result, if using device with A2 = high, and not using addressing, hw address must be set to 0b1XX In such case, even if not using addressing, initalize your MCP23S17 chip with 0b1XX address, eg: mcp.begin_SPI(10, &SPI, 0b100);.

Warning

Some people have reported an undocumented bug that can potentially corrupt the I2C bus. It occurs if an MCP230XX input pin state changes during I2C readout. This should be very rare. For more information, see this forum post and this knowledge base article.

Similar MCP servers

Official

Everything

Reference server that exercises every MCP feature: tools, resources, prompts, sampling and more

MOmodelcontextprotocol/servers92k190 new stars in the last 7 days

Official

Time

Current time lookup and conversion between IANA timezones

MOmodelcontextprotocol/servers92k190 new stars in the last 7 days

Official

Context7

Up-to-date docs for AI agents

UPupstash/context766k288 new stars in the last 7 days

Reactive Resume

Free open-source resume builder with remote MCP tools for resumes and job applications.

REreactive-resume/reactive-resume46k207 new stars in the last 7 days

mcp-server

Puter MCP enables AI tools to interact with Puter: manage files, websites, workers, and more

HEHeyPuter/puter44k57 new stars in the last 7 days

mcp-go

A Go implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.

MAmark3labs/mcp-go9.3k24 new stars in the last 7 days