

The MCP23017 is a 16-bit I/O expander with serial interface provided by Microchip Technology Inc. It offers an easy way to add additional general-purpose input/output (GPIO) pins to a microcontroller via the I2C bus. This component is particularly useful in applications where additional I/Os are needed, such as in button matrices, LED control, or when interfacing with multiple sensors that do not have a digital interface.
Common applications include:








| Pin Number | Pin Name | Description |
|---|---|---|
| 1-2 | A0-A1 | Hardware address pins to configure the I2C address |
| 3 | A2 | Hardware address pin to configure the I2C address |
| 4 | VSS | Ground (0V) |
| 5 | SCL | Serial Clock Line for I2C |
| 6 | SDA | Serial Data Line for I2C |
| 7 | RESET | Active-low reset input |
| 8-9 | INTA-INTB | Interrupt output pins |
| 10-17 | GPA0-GPA7 | GPIO Port A pins |
| 18-25 | GPB0-GPB7 | GPIO Port B pins |
| 26 | VDD | Positive power supply |
To use the MCP23017 with an Arduino UNO, you can use the Adafruit MCP23017 Arduino library. Here is a simple example to initialize the MCP23017 and set all pins to output:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
// Create an MCP23017 object
Adafruit_MCP23017 mcp;
void setup() {
Wire.begin(); // Initialize I2C bus
mcp.begin(); // Initialize MCP23017 with default address 0x20
// Set all pins to output
for (int i = 0; i < 16; i++) {
mcp.pinMode(i, OUTPUT);
}
}
void loop() {
// Your code here to control the GPIO pins
}
Q: Can I use multiple MCP23017 devices on the same I2C bus? A: Yes, you can use up to 8 MCP23017 devices on the same I2C bus by configuring the A0, A1, and A2 pins to different addresses.
Q: What is the maximum I2C speed that MCP23017 supports? A: The MCP23017 supports I2C speeds up to 1.7 MHz.
Q: How do I use the interrupt feature of the MCP23017? A: Configure the interrupt control registers to define the interrupt condition for each pin, and connect the INTA or INTB pin to an interrupt-capable pin on your microcontroller.
This documentation provides a comprehensive guide to using the MCP23017 I/O expander. For more detailed information, refer to the MCP23017 datasheet provided by Microchip Technology Inc.