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.
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 Name | Pin ID |
---|---|---|---|
10 | 21 | GPA0 | 0 |
11 | 22 | GPA1 | 1 |
12 | 23 | GPA2 | 2 |
13 | 24 | GPA3 | 3 |
14 | 25 | GPA4 | 4 |
15 | 26 | GPA5 | 5 |
16 | 27 | GPA6 | 6 |
17 | 28 | GPA7 | 7 |
-- | 1 | GPB0 | 8 |
-- | 2 | GPB1 | 9 |
-- | 3 | GPB2 | 10 |
-- | 4 | GPB3 | 11 |
-- | 5 | GPB4 | 12 |
-- | 6 | GPB5 | 13 |
-- | 7 | GPB6 | 14 |
-- | 8 | GPB7 | 15 |