

The MCP23017, manufactured by AzDelivery, is a 16-bit I/O expander that communicates with microcontrollers via the I2C interface. It allows users to add additional input/output pins to their projects, making it an ideal solution for applications requiring more GPIOs than what is available on the microcontroller. The MCP23017 is highly versatile and can be used for both input and output operations, supporting features such as interrupt handling and configurable pull-up resistors.








The MCP23017 is designed to operate efficiently in a wide range of applications. Below are its key technical specifications:
| Parameter | Value |
|---|---|
| Operating Voltage | 1.8V to 5.5V |
| Communication Interface | I2C (up to 1.7 MHz) |
| Number of I/O Pins | 16 (organized as two 8-bit ports) |
| Maximum Sink Current | 25 mA per pin |
| Maximum Source Current | 25 mA per pin |
| Interrupt Capability | Yes (configurable for each pin) |
| Internal Pull-Up Resistors | Yes (100 kΩ typical) |
| Package Type | DIP, SOIC, SSOP |
The MCP23017 has 28 pins, with the following configuration:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1-3 | A2, A1, A0 | Address pins for I2C communication. Used to set the I2C address of the device. |
| 4 | RESET | Active-low reset input. Resets the device when pulled low. |
| 5 | INTB | Interrupt output for Port B. |
| 6 | INTA | Interrupt output for Port A. |
| 7-14 | GPA0-GPA7 | General-purpose I/O pins for Port A. |
| 15 | VSS | Ground (0V). |
| 16-23 | GPB0-GPB7 | General-purpose I/O pins for Port B. |
| 24 | VDD | Power supply (1.8V to 5.5V). |
| 25 | SCL | I2C clock line. |
| 26 | SDA | I2C data line. |
| 27 | NC | No connection. |
| 28 | NC | No connection. |
The MCP23017 is straightforward to use in a circuit. Below are the steps and considerations for integrating it into your project:
Below is an example of how to use the MCP23017 with an Arduino UNO to control LEDs and read switches.
#include <Wire.h>
#include "Adafruit_MCP23017.h"
// Create an MCP23017 object
Adafruit_MCP23017 mcp;
void setup() {
Wire.begin(); // Initialize I2C communication
mcp.begin(); // Initialize MCP23017 with default address (0x20)
// Configure GPA0-GPA3 as outputs for LEDs
for (int i = 0; i < 4; i++) {
mcp.pinMode(i, OUTPUT);
}
// Configure GPB0-GPB3 as inputs for switches
for (int i = 8; i < 12; i++) {
mcp.pinMode(i, INPUT);
mcp.pullUp(i, HIGH); // Enable internal pull-up resistors
}
}
void loop() {
// Turn on LEDs connected to GPA0-GPA3
for (int i = 0; i < 4; i++) {
mcp.digitalWrite(i, HIGH);
delay(500); // Wait for 500ms
mcp.digitalWrite(i, LOW);
}
// Read switches connected to GPB0-GPB3
for (int i = 8; i < 12; i++) {
if (mcp.digitalRead(i) == LOW) {
// Switch is pressed
Serial.print("Switch ");
Serial.print(i - 8);
Serial.println(" is pressed");
}
}
}
I2C Communication Failure:
GPIO Pins Not Responding:
Interrupts Not Triggering:
Can the MCP23017 operate at 3.3V?
How many MCP23017 devices can I connect to a single I2C bus?
What is the maximum I2C clock speed supported?
Can I use the MCP23017 with a Raspberry Pi?