← All parts
MCP23S17
MCP23S17
IO expander / level shift
MCP23S17 16-bit SPI I/O expander (28-pin DIP) — two 8-bit ports (GPA/GPB) with interrupts.
In stock
Specifications
0No specs listed.
Pinout
28| Pin | Name | Functions | Notes |
|---|---|---|---|
| 1 | GPB0 | GPIO | Port B0 |
| 2 | GPB1 | GPIO | Port B1 |
| 3 | GPB2 | GPIO | Port B2 |
| 4 | GPB3 | GPIO | Port B3 |
| 5 | GPB4 | GPIO | Port B4 |
| 6 | GPB5 | GPIO | Port B5 |
| 7 | GPB6 | GPIO | Port B6 |
| 8 | GPB7 | GPIO | Port B7 |
| 9 | VDD | POWER | Supply |
| 10 | VSS | GND | Ground |
| 11 | CS | SPI | Chip select |
| 12 | SCK | SPI | SPI clock |
| 13 | SI | SPI | MOSI |
| 14 | SO | SPI | MISO |
| 15 | A0 | GPIO | Address 0 |
| 16 | A1 | GPIO | Address 1 |
| 17 | A2 | GPIO | Address 2 |
| 18 | RESET | GPIO | Reset |
| 19 | INTB | GPIO | Port B interrupt |
| 20 | INTA | GPIO | Port A interrupt |
| 21 | GPA0 | GPIO | Port A0 |
| 22 | GPA1 | GPIO | Port A1 |
| 23 | GPA2 | GPIO | Port A2 |
| 24 | GPA3 | GPIO | Port A3 |
| 25 | GPA4 | GPIO | Port A4 |
| 26 | GPA5 | GPIO | Port A5 |
| 27 | GPA6 | GPIO | Port A6 |
| 28 | GPA7 | GPIO | Port A7 |
Interactive pinout
Highlight:
MCP23S17
Click a pin to copy its name · tap a tag above to spotlight a bus.
Starter code
Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.
Arduino (C++)
Arduino library: Adafruit MCP23017 Arduino Library
arduino
// MCP23S17 16-bit SPI I/O expander — community starter example
#include <Adafruit_MCP23X17.h>
Adafruit_MCP23X17 mcp;
#if defined(ESP32)
#define CS_PIN 5
#else
#define CS_PIN 10
#endif
void setup() {
Serial.begin(115200);
if (!mcp.begin_SPI(CS_PIN)) { Serial.println("MCP23S17 not found"); while (1) delay(10); }
mcp.pinMode(0, OUTPUT); // port A, pin 0
mcp.pinMode(8, INPUT_PULLUP); // port B, pin 0
}
void loop() {
mcp.digitalWrite(0, HIGH);
delay(300);
mcp.digitalWrite(0, LOW);
delay(300);
Serial.println(mcp.digitalRead(8));
}MicroPython
python
# MCP23S17 SPI I/O expander (ESP32) — community starter example
# No common MicroPython driver: raw SPI register writes (IODIRA/GPIOA ...)
from machine import Pin, SPI
import time
spi = SPI(2, baudrate=1000000, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
cs = Pin(5, Pin.OUT, value=1)
OPCODE = 0x40 # device 0, write
def write_reg(reg, val):
cs.value(0); spi.write(bytes([OPCODE, reg, val])); cs.value(1)
write_reg(0x00, 0x00) # IODIRA: all of port A = outputs
while True:
write_reg(0x12, 0xFF); time.sleep(0.3) # GPIOA high
write_reg(0x12, 0x00); time.sleep(0.3) # GPIOA lowWiring
| Pin | Arduino Uno R3 | ESP32 DevKitC (WROOM-32) | Notes |
|---|---|---|---|
| VDD | +5V | 3V3 | 1.8-5.5 V |
| VSS | GND | GND | |
| SCK | D13 (SCK) | GPIO18 | |
| SI | D11 (MOSI) | GPIO23 | SPI data in |
| SO | D12 (MISO) | GPIO19 | SPI data out |
| CS | D10 | GPIO5 | Chip select |
| RESET | - | - | Tie to VDD (active-low) |
Typical uses
- 16 extra GPIO over SPI (faster than I2C)
- Button matrices and LED banks